ATG Customizing Log Formats
Since you know all component in ATG defaultly send their log events to a single logQueue component,we might need to customize log formats which best suits for our own components.
For formatting log messages for your own components,there were two OOTB classes provided by ATG
For formatting log messages for your own components,there were two OOTB classes provided by ATG
atg.service.datacollection.FormattingFileLogger and atg.service.datacollection.FormattingConsoleLogger
you can create your own logger components
you can create your own logger components
by creating the component(properties) for the class FormattingFileLogger/FormattingConsoleLogger.
Example
Example
#/xxx/xxx/xxx/xxx/xxxFormattingFileLogger
$class=atg.service.datacollection.FormattingFileLogger
$scope=global
# directory and file name
logFileDir=logs/application_logging
logFileName=myApp_
formatFields= '<',dateTimeStamp:d/MMM/yyyy:H:mm:ss,'>',' [',sessionID,'] ',browserID,'"',comma,'IP="',ipAddress,'"'
similar way you can create the Console Logger by removing the properties logFileDir,logFileName etc, as this is logged to the console.so i am not providing any example.
similar way you can create the Console Logger by removing the properties logFileDir,logFileName etc, as this is logged to the console.so i am not providing any example.
To Format your own component ,specify these two components in the logListeners property.
# /xxx/xxx/xxx/postLogin
$class=xxx.xxx.xxx.postLogin
$scope=global
# rotate file every day at 12:00AM
schedule= * * . * 0 0
scheduler=/atg/dynamo/service/Scheduler
logListeners=\
/xxx/xxx/xxx/xxx/xxxFormattingFileLogger,\
/xxx/xxx/xxx/xxx/xxxFormattingConsoleLogger
You are done !!!,now use the log statement inside your class,For Eg: logDebug(),you will see the logs generated in the format you wish or mentioned as per the formatFields property.
See also Logging Tips
You are done !!!,now use the log statement inside your class,For Eg: logDebug(),you will see the logs generated in the format you wish or mentioned as per the formatFields property.
See also Logging Tips
Comments
Post a Comment