Hello, I have a struts application in which i configured log4j. The application log messages getted logged in the log file, but I also get a lot of unwanted, apparently server generated, log messages. How do i stop these unwanted messages from being logged in my application log file?
my log4j.properties has follwoing configuration:: log4j.rootLogger=debug, haps log4j.appender.haps=org.apache.log4j.RollingFileAppender log4j.appender.haps.File=d:/bea/user_projects/mydomain/hapsAppMessages.log log4j.appender.haps.MaxFileSize=500000KB log4j.appender.haps.MaxBackupIndex=3 log4j.appender.haps.layout=org.apache.log4j.PatternLayout log4j.appender.haps.layout.ConversionPattern=%d %-5p %C - %m%n
Do i have to change anything in this file? or do i change anything else in my application server ( BEA WebLogic 8.1) configuration?! Some advice on this matter would be really helpful.
The non-application related log messages that I get are something like this:: 005-09-29 11:22:26,750 INFO org.apache.struts.util.PropertyMessageResources - Initializing, config='org.apache.struts.util.LocalStrings', returnNull=true 2005-09-29 11:22:26,781 INFO org.apache.struts.util.PropertyMessageResources - Initializing, config='org.apache.struts.action.ActionResources', returnNull=true 2005-09-29 11:22:26,843 DEBUG org.apache.commons.digester.Digester - register('-//Apache Software Foundation//DTD Struts Configuration 1.0//EN', 2005-09-29 11:23:58,171 DEBUG org.apache.commons.beanutils.ConvertUtils - Using converter org.apache.commons.beanutils.converters.StringConverter@1f95673 2005-09-29 11:23:58,171 DEBUG org.apache.commons.beanutils.BeanUtils - setProperty(com.au.optus.delphi.web.form.hbu.HBUExistingEquipmentsForm@1716083, model, ) 2005-09-29 11:23:58,171 DEBUG org.apache.commons.beanutils.ConvertUtils - Convert string '1108' to class 'java.lang.String' 2005-09-29 11:23:58,171 DEBUG org.apache.commons.beanutils.ConvertUtils - Using converter org.apache.commons.beanutils.converters.StringConverter@1f95673 2005-09-29 11:23:58,171 DEBUG org.apache.struts.action.RequestProcessor - Validating input form properties
I wouldn't be too sure that these are coming from the server - are you using Struts (which is where these are coming from) ? In log4j you can add something like the following to your setup, in which case you'll only get the more important messages: log4j.logger.org.apache = WARN, haps or you can set up a second logger to capture them there.
Yes mine is a Struts application, and the log messages are of struts itself. The suggestion that you made, sure works. But that means all the messages taht I need to log, would be of priority WARN, which is not right. Is there any way in which my application log messages of all levels - debug, info and so on, be logged in a separate file without any struts messages !?!? I modified my log4j.properties as follows, but this does not work either, all messages get logged in the root appender with struts + application messages.
But that means all the messages taht I need to log, would be of priority WARN, which is not right.
No, it does not. It means that all messages coming from classes in the org.apache hierarchy must be of level WARNING or higher to be logged. For all other messages the level you defined is used (which is DEBUG in your example). Thus none of the DEBUG or INFO messages from Struts would be logged.