Tobia
Tobia

Reputation: 9526

Log4J log path in a servlet (TOMCAT)

I want to set up my log4j log path with a db param. My log4j properties is this:

 log4j.appender.file.File=${log.app.path}/app/app1.log

I populated the System property ${log.app.path} with a JVM var. Now I would like to set that path with a value in database. Than I thought to set it with a ServletContextListener but I found that the log4j is aready running.

Any suggestions? Thank you.

Upvotes: 1

Views: 409

Answers (2)

Marcus Blackhall
Marcus Blackhall

Reputation: 326

Have you tried using the log4j jdbcappender ?

link is :

http://www.tutorialspoint.com/log4j/log4j_logging_database.htm

Upvotes: 0

Kris
Kris

Reputation: 8873

You can always initialize a logger with a FileAppender in the code. You can just use the value you want( from db or where ever) and set the params for FileAppender in to the Logger Object.

Upvotes: 1

Related Questions