You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-user@logging.apache.org by Yi Chen <yi...@verizon.com> on 2002/11/29 17:21:59 UTC

weblogic6.1 & log4j

Do we have anyone is this list using log4j for weblogic6.1 based web
application? I found something strange: the logger (created in a jsp page)
can write to the weblogic console even I didn't config the console appender
in log4j.propertiesl and I don't see any output to the assigned log file. By
the way, I put log4j.properties in weblogic classpath. Any information will
be appreciated.

Thanks,

Yi



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re:Re: can each thread has a logfile?

Posted by Li YuanHao <li...@hotmail.com>.
Thank you very much!
You give me great help.

----- Original Message -----
From: "Thomas Muller" <tt...@online.no>
To: "Log4J Users List" <lo...@jakarta.apache.org>
Sent: Tuesday, December 03, 2002 6:39 PM
Subject: RE: can each thread has a logfile?


> Li,
>
> As far as I understand log4j has no built-in mechanism aimed at
facilitating
> what you ask for, but it's not hard to code this functionality yourself.
You
> can e.g. use java.lang.ThreadLocal.
>
> public class Foo {
>
>    private static final ThreadLocal THREAD_LOCAL_LOGGER = new
ThreadLocal()
> {
>
>             protected synchronized Object initialValue() {
>                 String name = Thread.currentThread().getName();
>                 Logger logger = Logger.getLogger( name );
>                 logger.addAppender( new FileAppender( "%d{ABSOLUTE} %m%n",
>                      System.getProperty( "user.dir" ) + File.separator +
> name, false ) );
>                 return logger;
>             }
>
>             public void set( Object o ) {
>                 throw new UnsupportedOperationException();
>             }
>        };
>
>    // Returns thread local logger
>    private static Logger getLogger() {
>        return ( Logger ) THREAD_LOCAL_LOGGER.get();
>    }
>
>    public void doSomething() {
>       getLogger().debug( "foobar" );
>       // (.....)
>    }
>
> }
>
> Hope this helps,
>
> --
>
> Thomas
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> | -----Original Message-----
> | From: Li YuanHao [mailto:li_yuanhao@hotmail.com]
> | Sent: 03 December 2002 01:07
> | To: Log4J Users List
> | Subject: Re: can each thread has a logfile?
> |
> |
> |  Hi,Could anyone tell me THAT whether I can configure log4j to log each
> |  thread to each self logfile?
> |  Could you give a sample?
> |  Any advice is appreciated .
> |
> | --
> | To unsubscribe, e-mail:
> | <ma...@jakarta.apache.org>
> | For additional commands, e-mail:
> | <ma...@jakarta.apache.org>
> |
> |
>
>
>
> *************************************************************************
> Copyright ERA Technology Ltd. 2002. (www.era.co.uk). All rights reserved.
> The information supplied in this Commercial Communication should be
treated
> in confidence.
> No liability whatsoever is accepted for any loss or damage
> suffered as a result of accessing this message or any attachments.
>
> ________________________________________________________________________
> This email has been scanned for all viruses by the MessageLabs SkyScan
> service. For more information on a proactive anti-virus service working
> around the clock, around the globe, visit http://www.messagelabs.com
> ________________________________________________________________________
>
> --
> To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
> For additional commands, e-mail:
<ma...@jakarta.apache.org>
>

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


RE: can each thread has a logfile?

Posted by Thomas Muller <tt...@online.no>.
Li,

As far as I understand log4j has no built-in mechanism aimed at facilitating
what you ask for, but it's not hard to code this functionality yourself. You
can e.g. use java.lang.ThreadLocal.

public class Foo {

   private static final ThreadLocal THREAD_LOCAL_LOGGER = new ThreadLocal()
{

            protected synchronized Object initialValue() {
                String name = Thread.currentThread().getName();
                Logger logger = Logger.getLogger( name );
                logger.addAppender( new FileAppender( "%d{ABSOLUTE} %m%n",
                     System.getProperty( "user.dir" ) + File.separator +
name, false ) );
                return logger;
            }

            public void set( Object o ) {
                throw new UnsupportedOperationException();
            }
       };

   // Returns thread local logger
   private static Logger getLogger() {
       return ( Logger ) THREAD_LOCAL_LOGGER.get();
   }

   public void doSomething() {
      getLogger().debug( "foobar" );
      // (.....)
   }

}

Hope this helps,

--

Thomas














| -----Original Message-----
| From: Li YuanHao [mailto:li_yuanhao@hotmail.com]
| Sent: 03 December 2002 01:07
| To: Log4J Users List
| Subject: Re: can each thread has a logfile?
|
|
|  Hi,Could anyone tell me THAT whether I can configure log4j to log each
|  thread to each self logfile?
|  Could you give a sample?
|  Any advice is appreciated .
|
| --
| To unsubscribe, e-mail:
| <ma...@jakarta.apache.org>
| For additional commands, e-mail:
| <ma...@jakarta.apache.org>
|
|



*************************************************************************
Copyright ERA Technology Ltd. 2002. (www.era.co.uk). All rights reserved. 
The information supplied in this Commercial Communication should be treated
in confidence.
No liability whatsoever is accepted for any loss or damage 
suffered as a result of accessing this message or any attachments.

________________________________________________________________________
This email has been scanned for all viruses by the MessageLabs SkyScan
service. For more information on a proactive anti-virus service working
around the clock, around the globe, visit http://www.messagelabs.com
________________________________________________________________________

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: can each thread has a logfile?

Posted by Li YuanHao <li...@hotmail.com>.
 Hi,Could anyone tell me THAT whether I can configure log4j to log each
 thread to each self logfile?
 Could you give a sample?
 Any advice is appreciated .

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


can each thread has a logfile?

Posted by Li YuanHao <li...@hotmail.com>.
Hi,Could anyone tell me THAT whether I can configure log4j to log each
thread to each self logfile?
Could you give a sample?
Any advice is appreciated .

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>