Breaking News
Home / ServerSide / How does a typical Log4j configuration looks like?

How does a typical Log4j configuration looks like?

Answer

Log4J is a very popular and commonly used logging implementation that is used in the Enterprise or Server Side Application. Log4j can be configured via a properties file or an xml file. The below is an example of configuring Log4j using a properties file. Generally for simplicity the file name is called as log4j.properties but can be anything.

Typical Configuration

log4j.rootLogger=trace,stdout,R

log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d[%t]%-5p%c{1}%x-%m%n

log4j.appender.R=org.apache.log4j.RollingFileAppender
log4j.appender.R.File=../logs/server.log
log4j.appender.R.MaxFileSize=1024KB
log4j.appender.R.MaxBackupIndex=5
log4j.appender.R.layout=org.apache.log4j.PatternLayout
log4j.appender.R.layout.ConversionPattern=%d[%t]%-5p%c{1}%x-%m%n

Sample Output

2012-01-03 16:58:18,970[Thread-45]DEBUG JSONServiceActionHandler -Parsing Done
2012-01-03 16:58:18,970[Thread-45]TRACE SubscriptionXmlService -in : -uploadData (.)
2012-01-03 16:58:18,970[Thread-45]DEBUG WorkflowExecutor -method : execute()
2012-01-03 16:58:18,970[Thread-45]TRACE SubscriptionUploadWorkflow -in :validateProcess()
2012-01-03 16:58:18,970[Thread-45]TRACE SubscriptionUploadWorkflow -in :initializeProcess()
2012-01-03 16:58:18,970[Thread-45]TRACE SubscriptionUploadWorkflow -in :executeProcess()
2012-01-03 16:58:18,970[Thread-45]DEBUG SubscriptionDao -subscription guid11klA1EpO5fq95OvNLicMQ==
2012-01-03 16:58:18,972[Thread-45]DEBUG SubscriptionDao -retrieved subscription
2012-01-03 16:58:18,977[Thread-45]DEBUG SubscriptionUploadWorkflow -Decoded upload data : 97255
2012-01-03 16:58:18,977[Thread-45]DEBUG SubscriptionUploadWorkflow -File save path : /Users/mvohra/workspace/projects/infuze/uploads/16-1325638698977.png
2012-01-03 16:58:19,042[Thread-45]DEBUG SubscriptionDao -com.infuze.service.subscription.entity.SubscriptionUploadDto@1c5aebd9
2012-01-03 16:58:19,096[Thread-45]DEBUG SubscriptionDao -subscription upload  added successfully
2012-01-03 16:58:19,096[Thread-45]DEBUG SubscriptionDao -in :updateSubscriptionUnits(-1)
2012-01-03 16:58:19,098[Thread-45]DEBUG SubscriptionDao -subscription units updated successfully

Please make sure this file log4j.properties is in the class path and specify the file name as a value to environment variable -Dlog4j.properties=log4j.properties in your startup script , rest it will configure automatically.

[pb_builder]

Check Also

What webservices standards are supported by Siebel Business Applications?

The following Web services standards are supported by Siebel Business Applications:     * Web Services …

Advertisment ad adsense adlogger