• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Tim Cooke
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • paul wheaton
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Tim Holloway
  • Carey Brown
  • salvin francis

log4j: Reading Log level from DB

 
Ranch Hand
Posts: 123
Hibernate Spring Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Forum,

Normally log level is set in log4j.properties file.

Is there any way to set log level kept in Database?

In short I don't want to read log level from properties file.

Thanks
 
author
Posts: 3281
8
Mac OS X Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hmm, not that I've heard of, can I ask _why_ you want to read it from a DB?
 
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You could read the log level from the database before configuering log4j, set the log level as a system property and reference this property in the log4j properties.

I never did this with the loglevel, but with the log file path.

Java Code:


log4j.xml:
 
Aakash Parashar
Ranch Hand
Posts: 123
Hibernate Spring Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Friends,

I got answer of my question.

PropertyConfigurator - this class is present on log4j.
PropertyConfigurator.configure(prop); //prop is a Property object

The configure method is used to load the properties which are present in a Property type of object.

The key and value in Property type of object can be read from DB, properties file or any resource present inside or outside object.

PropertyConfigurator.configure() method will set the properties in the log4j environment.
[ December 03, 2008: Message edited by: Aakash ]
 
Martijn Verburg
author
Posts: 3281
8
Mac OS X Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for letting us know Aakash, interesting stuff!
 
Aakash Parashar
Ranch Hand
Posts: 123
Hibernate Spring Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Originally posted by Martijn Verburg:
Hmm, not that I've heard of, can I ask _why_ you want to read it from a DB?



We are putting log4j properties in a property file which is clubbed in EAR deployed. So for changing the log level we have to pull the properties file from EAR for changing and after changing we have to redeploy the EAR.

To escape from all this mess and complex process we were thinking of putting log level in DB.
 
What's brown and sticky? ... a stick. Or a tiny ad.
professionally read, modify and write PDF files from Java
https://products.aspose.com/pdf/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!