Results 1 to 4 of 4
Thread: log4j and struts
- 04-13-2010, 02:53 PM #1
Member
- Join Date
- Apr 2010
- Posts
- 2
- Rep Power
- 0
log4j and struts
Hi,
I am using log4j with struts, all configuration is working fine but now I have a requirement to read log4j xml param values using database here is example what i want
<appender name="debugfile"
class="org.apache.log4j.RollingFileAppender">
<param name="maxFileSize" value="**this i want from database
<param name="maxBackupIndex" value=" **this i want from database
<param name="File" value="**this i want from database
please help me out
Thanks in advance !!
- 04-13-2010, 04:15 PM #2
I imagine to do this,
- have the log4j.xml file generated, such as having a java process run before your application, to connect to the database, populate the value, perhaps by replacing a token in a template and writing out the log4j,xml file, then starting your application up, which would conveniently now find this generated log4j.xml in its classpath.
- use the programmatic API to configure the log4j. See the log4j java API documentation, where you might do something like
I think this hybrid reconfiguration would allow the logger settings and levels defined in the log4j.xml to still work. Maybe you would not need to remove all existing appenders first.Java Code:String filename = "thefilename"; Layout layout = new PatternLayout(...); RollingFileAppender appender = new RollingFileAppender(layout, filename); int maxFileSize = // this is where you invoke your database query to get the value to use. appender.setMaxFileSize(maxFileSize); // and make this appender be used Logger logger = Logger.getRootLogger(); logger.removeAllAppenders(); logger.addAppender(appender);
- 04-14-2010, 10:51 AM #3
Member
- Join Date
- Apr 2010
- Posts
- 2
- Rep Power
- 0
Travishein thanks for Reply !!
:confused::confused:
I want to chang log4j.xml based on user login !!
suppose if type A user login then I want different log4j configuration and if type B user login then I want different log4j configuration .....
is it possible for me ?? :rolleyes::rolleyes:
Thanks again for reply
- 05-23-2010, 02:13 AM #4
Similar Threads
-
log4j
By swapna_d in forum New To JavaReplies: 7Last Post: 08-04-2010, 12:23 AM -
decorator.jsp problem building Struts Menu in JSP when Struts action is used
By dkirvan in forum JavaServer Pages (JSP) and JSTLReplies: 3Last Post: 04-29-2010, 05:33 AM -
Regarding Log4j
By sidiq in forum New To JavaReplies: 0Last Post: 04-07-2008, 07:35 PM -
log4j not working in struts
By Manu in forum Web FrameworksReplies: 0Last Post: 03-19-2008, 02:54 PM -
Log4j
By chakri in forum New To JavaReplies: 1Last Post: 02-08-2008, 10:15 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks