You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Lorenzo Sicilia <ar...@kemen.it> on 2005/10/24 17:14:04 UTC

turn off log4j

Hi to all,

I have a webapplication with struts where I want use log4j.

in my log4j.properties:
log4j.rootLogger=debug, stdout, R

#log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout

# Pattern to output the caller's file name and line number.
log4j.appender.stdout.layout.ConversionPattern=%5p [%t] (%F:%L) - %m%n

log4j.appender.R=org.apache.log4j.RollingFileAppender
log4j.appender.R.File=/home/lorenzo/Desktop/example.log

log4j.appender.R.MaxFileSize=100KB
# Keep one backup file
log4j.appender.R.MaxBackupIndex=1

log4j.appender.R.layout=org.apache.log4j.PatternLayout
log4j.appender.R.layout.ConversionPattern=%p %t %c - %m%n

when the application start I get this output:
...
DEBUG [ContainerBackgroundProcessor[StandardEngine[Catalina]]] 
(PropertyMessageResources.java:132) - getMessage(en_US,finalizing)
DEBUG [ContainerBackgroundProcessor[StandardEngine[Catalina]]] 
(PropertyMessageResources.java:224) - loadLocale(en_US)
DEBUG [ContainerBackgroundProcessor[StandardEngine[Catalina]]] 
(PropertyMessageResources.java:246) -   Loading resource 
'org/apache/struts/action/ActionResources_en_US.properties'
...

I use a Init log4j servlet with this snippets in web.xml
<servlet>
    <servlet-name>log4j-init</servlet-name>
    <servlet-class>it.kemen.util.InitLog</servlet-class>

    <init-param>
      <param-name>log4j-init-file</param-name>
      <param-value>WEB-INF/log4j.properties</param-value>
    </init-param>

    <load-on-startup>1</load-on-startup>
  </servlet>

Can I esclude struts output log? I want just the log from my package

thanks in advance.

regards Lorenzo

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: turn off log4j

Posted by Lorenzo Sicilia <ar...@kemen.it>.
On Monday 24 October 2005 18:30, Lorenzo Sicilia wrote:
> Just a strange behavior about actions. It logs but with a different layout

I fix the behavior when I changed in LoginAction this row:
private static Logger logger = Logger.getLogger(LoginAction.class.getName())
to
private static Log logger = LogFactory.getLog(LoginAction.class);

regards Lorenzo Sicilia

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: turn off log4j

Posted by Lorenzo Sicilia <ar...@kemen.it>.
On Monday 24 October 2005 17:28, Samuel Le Berrigaud wrote:
> # the root logger is OFF (OFF doesn't mean anything to log4j)
> log4j.rootLogger = OFF
>
> # logging your package
> log4j.logger.yourpackage = debug, stdout, R

many thanks for the answer it works fine.
Just a strange behavior about actions. It logs but with a different layout

class com.mydomain.util.InitLog:
INFO 2005-10-24 18:11:33,553 com.mydomain.util.InitLog (InitLog.java:22) - 
START web! 
(perfect)
class it.
Oct 24, 2005 6:11:39 PM com.mydomain.action.LoginAction execute
INFO: test action
(quite fine but with a different layout)

in log4j.properties:
#log4j.rootLogger=OFF
log4j.rootLogger = OFF
log4j.logger.com.domain = debug, stdout, R
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout

# Pattern to output the caller's file name and line number.
log4j.appender.stdout.layout.ConversionPattern=%5p %d %c (%F:%L) - %m%n

log4j.appender.R=org.apache.log4j.RollingFileAppender
log4j.appender.R.File=/home/lorenzo/Desktop/example.log

log4j.appender.R.MaxFileSize=100KB
# Keep one backup file
log4j.appender.R.MaxBackupIndex=1

log4j.appender.R.layout=org.apache.log4j.PatternLayout
log4j.appender.R.layout.ConversionPattern=%5p %d %c (%F:%L) - %m%n

It would be nice if com.mydomain.action.LoginAction use this pattern"%5p %d %c 
(%F:%L) - %m%n"

anyway many thanks

regards Lorenzo

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: turn off log4j

Posted by Samuel Le Berrigaud <sa...@gmail.com>.
You may want to log4j file to look like that then

# the root logger is OFF (OFF doesn't mean anything to log4j)
log4j.rootLogger = OFF

# logging your package
log4j.logger.yourpackage = debug, stdout, R

## then the rest of your appenders

SaM

On 10/24/05, Lorenzo Sicilia <ar...@kemen.it> wrote:
>
> Hi to all,
>
> I have a webapplication with struts where I want use log4j.
>
> in my log4j.properties:
> log4j.rootLogger=debug, stdout, R
>
> #log4j.appender.stdout=org.apache.log4j.ConsoleAppender
> log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
>
> # Pattern to output the caller's file name and line number.
> log4j.appender.stdout.layout.ConversionPattern=%5p [%t] (%F:%L) - %m%n
>
> log4j.appender.R=org.apache.log4j.RollingFileAppender
> log4j.appender.R.File=/home/lorenzo/Desktop/example.log
>
> log4j.appender.R.MaxFileSize=100KB
> # Keep one backup file
> log4j.appender.R.MaxBackupIndex=1
>
> log4j.appender.R.layout=org.apache.log4j.PatternLayout
> log4j.appender.R.layout.ConversionPattern=%p %t %c - %m%n
>
> when the application start I get this output:
> ...
> DEBUG [ContainerBackgroundProcessor[StandardEngine[Catalina]]]
> (PropertyMessageResources.java:132) - getMessage(en_US,finalizing)
> DEBUG [ContainerBackgroundProcessor[StandardEngine[Catalina]]]
> (PropertyMessageResources.java:224) - loadLocale(en_US)
> DEBUG [ContainerBackgroundProcessor[StandardEngine[Catalina]]]
> (PropertyMessageResources.java:246) - Loading resource
> 'org/apache/struts/action/ActionResources_en_US.properties'
> ...
>
> I use a Init log4j servlet with this snippets in web.xml
> <servlet>
> <servlet-name>log4j-init</servlet-name>
> <servlet-class>it.kemen.util.InitLog</servlet-class>
>
> <init-param>
> <param-name>log4j-init-file</param-name>
> <param-value>WEB-INF/log4j.properties</param-value>
> </init-param>
>
> <load-on-startup>1</load-on-startup>
> </servlet>
>
> Can I esclude struts output log? I want just the log from my package
>
> thanks in advance.
>
> regards Lorenzo
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>


--
Samuel Le Berrigaud