Log4j Dynamic Parameter

Posted by cedric on Stack Overflow See other posts from Stack Overflow or by cedric
Published on 2010-03-23T05:36:04Z Indexed on 2010/03/23 5:43 UTC
Read the original article Hit count: 442

Filed under:
|
|

Hi. i have a j2ee web application running on spring framework and using log4j for logging. I have this line in my log4j.properties file. this will insert the logs in my database. How do I set a dynamic value in the message part so that I can somehow append the currently logged in user. The bean object containing info for the current user is in the application context.

log4j.appender.dbLog.sql = INSERT INTO LOGGING (log_date, log_level, location, message) VALUES ('%d{yyyy/MM/dd HH:mm:ss}', '%-5p', '%C-%L', '%m')

© Stack Overflow or respective owner

Related posts about log4j

Related posts about dynamic