Have Date and Time on Log Files?

If you have questions or if you want to share your opinion about Aware IM post your message on this forum
Post Reply
BLOMASKY
Posts: 1471
Joined: Wed Sep 30, 2015 10:08 pm
Location: Ocala FL

Have Date and Time on Log Files?

Post by BLOMASKY »

I am SO not smart enough to mess with the Logging system (I am still confused what the Appenders are...)

But, I wonder how hard it would be to have all of the logging (When I say ALL, I mean the Aware, Tomcat and Main and Testing Logging) all have the date and time pre-pended to it. This would be great when a user tells me of an issue and they say it happed at 9:26AM.

Bruce
PointsWell
Posts: 1457
Joined: Tue Jan 24, 2017 5:51 am
Location: 'Stralya

Re: Have Date and Time on Log Files?

Post by PointsWell »

Hi Bruce

I have updated the server.xml file in Tomcat/conf to add a Valve with the following details:

Code: Select all

<Host name="localhost"  appBase="webapps"
            unpackWARs="true" autoDeploy="true">

        <!-- SingleSignOn valve, share authentication between web applications Documentation at: /docs/config/valve.html -->
        <!-- Access log processes all example.
             Documentation at: /docs/config/valve.html
             Note: The pattern used is equivalent to using pattern="common" -->
        <Valve className="org.apache.catalina.valves.AccessLogValve" directory="/opt/awarelogs/tomcat/logs/localhost"
               prefix="localhost_access_log" suffix=".txt"
               pattern="%h %l %u %t "%r" %s %b" />
This creates a log file with the format:
localhost_access_log.2018-12-04.txt

You can probably adjust the pattern to add time onto it as well, though I don't know how you update the AccessLogValve to roll the files more frequently.

I have attached a commented logger.props (it is not a real zip save it and remove the .zip to return it to a text suffix) file which hopefully will give you a guide to what the appenders are doing and how you can play with them. Do not use the Database appender, it doesn't work very well with the version of Log4j that ships with AIM.

Note if you replace the logger.props file in your installation with this one, then it will switch off the logging for the server and divert it to the settings in the file - so better to use it as a reference only.

Also check out this page https://www.tutorialspoint.com/log4j/index.htm
Attachments
logger.txt.zip
(15.71 KiB) Downloaded 284 times
Post Reply