Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not getting error traces in json format. #3307

Open
nishant24011998 opened this issue Dec 18, 2024 · 1 comment
Open

Not getting error traces in json format. #3307

nishant24011998 opened this issue Dec 18, 2024 · 1 comment

Comments

@nishant24011998
Copy link

nishant24011998 commented Dec 18, 2024

Description

We are using log4j 2.17.1 version and along we are using json template attached below. In some cases, we are not getting error traces in json format such as -:

{"time":"XXX","level":"XXX","module":"XXX","class":"XXX","message":"XXXX"}
Exception in thread "main" java.lang.ExceptionInInitializerError
	at com.rjil.cloud.drive.repository.SecDBRepository.getInstance(SecDBRepository.java:57)
	at com.rjil.drive.sio.cons.bootstrap.SIOConsumerBootstrap.populateStorageCache(SIOConsumerBootstrap.java:105)
	at com.rjil.drive.sio.cons.bootstrap.SIOConsumerBootstrap.preBootstrap(SIOConsumerBootstrap.java:74)
	at com.rjil.drive.sio.cons.main.SIOConsumerInit.bootstrapRuntime(SIOConsumerInit.java:85)
	at com.rjil.drive.sio.cons.main.SIOConsumerInit.main(SIOConsumerInit.java:36)
Caused by: ApplicationRepositoryException (a11db359-aca8-4943-a02b-4759966e596d): 500 Internal Server Error, SQL not found for query id :: sec.headless.schema
	at com.rjil.cloud.drive.repository.SecDBRepository.<init>(SecDBRepository.java:44)
	at com.rjil.cloud.drive.repository.SecDBRepository$Singleton.<clinit>(SecDBRepository.java:49)
	... 5 more
Caused by: java.util.InvalidPropertiesFormatException: SQL not found for query id :: sec.headless.schema
	at com.rjil.cloud.drive.repository.QueryLoader.getQuery(QueryLoader.java:107)
	at com.rjil.cloud.drive.repository.SecDBRepository.<init>(SecDBRepository.java:38)
	... 6 more

My Log4j is as follow:- 
	<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="ERROR">
	<Properties>
		<Property name="log-path">/usrdata/logs/applogs</Property>
		<Property name="json-template-path">/usrdata/apps/appserver/netty/props/</Property>
		<!--<Property name="json-template-path">/usrdata/GitRepo/enterpriseAdminConsoleUpgrade/Deployment/dev</Property>-->
	</Properties>
	<Appenders>
		<RollingFile name="RollingFile" fileName="XXXXXX" filePattern="XXXXX.gz">
			<JsonTemplateLayout eventTemplateUri="file://${json-template-path}/JsonTemplate.json"/>
			<Policies>
				<SizeBasedTriggeringPolicy size="100 MB" />
				<TimeBasedTriggeringPolicy interval="3600" modulate="true" />
			</Policies>
			<DefaultRolloverStrategy max="20" />
		</RollingFile>
		<!--<RollingFile name="RollingFile" fileName="XXX" filePattern="$XXXX">
			<PatternLayout>
				<pattern>[%d{dd-MMM-yyyy HH:mm:ss.SSS}] [%-5p] [%X{SEVERITY}] [%X{MICRO_SERVICE_CODE}] [%t] [%X{USER_ID}] [%X{DEVICE_KEY}] [%X{REQUEST_ID}] [%X{HTTP_FORWARDER_DETAILS}] [%X{HTTP_RESPONSE_CODE}] [%X{TEJ_ERROR_CODE}] [%c] %m%n</pattern>
			</PatternLayout>
			<Policies>
				<SizeBasedTriggeringPolicy size="100 MB" />
				<TimeBasedTriggeringPolicy interval="3600" modulate="true" />
			</Policies>
			<DefaultRolloverStrategy max="20" />
		</RollingFile>-->

		<File name="File" fileName="${log-path}/service-healthCheck.log" append="false">
            <PatternLayout pattern="%m%n" />
        </File>
		<RollingFile name="BusinessEvent" fileName="${log-path}/business-event.log" filePattern="${log-path}/archives/business-event-%d{MM-dd-yy-HH-mm-ss}-%i.log.gz">
            <PatternLayout>
				<pattern>[%d{dd-MMM-yyyy HH:mm:ss.SSS}] [%-5p] [%X{SEVERITY}] [%X{MICRO_SERVICE_CODE}] [%t] [%X{USER_ID}] [%X{DEVICE_KEY}] [%X{REQUEST_ID}] [%X{HTTP_FORWARDER_DETAILS}] [%X{HTTP_RESPONSE_CODE}] [%X{TEJ_ERROR_CODE}] [%c] %m%n</pattern>
			</PatternLayout>
			<Policies>
				<SizeBasedTriggeringPolicy size="100 MB" />
				<TimeBasedTriggeringPolicy interval="3600" modulate="true" />
			</Policies>
			<DefaultRolloverStrategy max="20" />
		</RollingFile>
		<!--<Console name="BusinessEvent" target="SYSTEM_OUT">
			<PatternLayout>
				<pattern>[%d{dd-MMM-yyyy HH:mm:ss.SSS}] [%-5p] [%X{SEVERITY}] [%X{MICRO_SERVICE_CODE}] [%t] [%X{USER_ID}] [%X{DEVICE_KEY}] [%X{REQUEST_ID}] [%X{HTTP_FORWARDER_DETAILS}] [%X{HTTP_RESPONSE_CODE}] [%X{TEJ_ERROR_CODE}] [%c] %m%n</pattern>
			</PatternLayout>
	    </Console>-->

	</Appenders>
	<Loggers>
		<!-- Cassandra Driver Logs -->
		<Logger name="com.datastax.driver.core.QueryLogger" level="ERROR" />
       	<Logger name="com.datastax.driver.core.Cluster" level="ERROR" />
        <Logger name="com.datastax.driver.core.Session" level="ERROR" />
        <Logger name="com.datastax.driver.core.RequestHandler" level="ERROR" />
        <Logger name="com.datastax.driver.core.Connection" level="ERROR" />
        <Logger name="com.datastax.driver.core.Message" level="ERROR" />
        
        <!-- Apache HTTP Client and Netty Logs -->
        <Logger name="org.apache.http.wire" level="WARN"/>
		<Logger name="io.netty.channel" level="WARN"/>
		<Logger name="io.netty.buffer" level="WARN"/>
		<Logger name="io.netty.util" level="WARN"/>
		<Logger name="org.apache.http" level="WARN"/>
		<Logger name="org.apache.http.impl.conn.DefaultClientConnection" level="WARN"/>
		
		<!-- HikariCP Pool Logs -->
		<Logger name="XXXX" level="WARN"/>
		<Logger name="XXXX" level="WARN"/>
		
		<!-- Turn off other logging -->
		<Logger name="XXXXX" level="OFF"/>
		<Logger name="XXXX" level="OFF"/>
		<Logger name="XXXX" level="OFF"/>
		<Logger name="XXXX" level="OFF"/>
		<Logger name="XXXX" level="WARN"/>
		<Logger name="XXXX" level="WARN"/>
		<Logger name="XXXX" level="ERROR"/>

		<Logger name="cXXXX" level="INFO" additivity="false">
            <AppenderRef ref="File"/>
         </Logger>
         <Logger name="XXXX" level="INFO" additivity="false">
            <AppenderRef ref="BusinessEvent"/>
        </Logger>
		<Root level="info" additivity="false">
			<AppenderRef ref="RollingFile" />
		</Root>
	</Loggers>

I have also attached my JsonTemplate.json as well along with this.

JsonTemplate.json

@ppkarwasz
Copy link
Contributor

@nishant24011998,

Exception in thread "main" java.lang.ExceptionInInitializerError
    ...

This does not look as the normal stack trace of a log event, but the output of Thread.UncaughtExceptionHandler. Are you sure this in the content of a log file and not on System.err?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants