Greg Flex | 1 May 03:30 2009
Picon

Re: XMLLaout

I've figure it out.....
LocationInfo needs to be set to true to get these values. (default is false)
For those interested here is the proper XMLLayout file.

<!-- log info level into log.xml -->
     <appender name="XMLOUT" class="org.apache.log4j.FileAppender">
        <param name="File" value="C:\\tmp\\log.xml"/>
        <param name="Threshold" value="info"/>
        <layout class="org.apache.log4j.xml.XMLLayout">
            <param name="LocationInfo" value="true"/>
        </layout>
    </appender>

Greg

On Thu, Apr 30, 2009 at 11:55 AM, Greg Flex <greg.flex <at> gmail.com> wrote:

> Hi Guys,
> I have this for now in my config.xml file that configures the logger.
>
> <appender name="XMLOUT" class="org.apache.log4j.FileAppender">
>      <param name="File" value="C:\\tmp\\log.xml"/>
>      <param name="Threshold" value="info"/>
>      <layout class="org.apache.log4j.xml.XMLLayout"/>
> </appender>
>
> It all works just fine but when I view logs with the Chainsaw I'm not
> getting any class name or a method name or line number.
> In fact, I'm not getting anything that I'd need.
> I can get all these values when I use the file appender with the
(Continue reading)

Michael Erskine | 1 May 10:01 2009

RE: Warning in Javadoc of JDBCAppender

> WARNING: This version of JDBCAppender is very likely to be completely replaced
> in the future. Moreoever, it does not log exceptions.
>
> Is this warning still accurate? The latest version of 1.2 is almost 2 years
> old ... is JDBCAppender going to be replaced one day?

I'm sure those familiar with the shortcomings of JDBCAppender just write their own custom appender - it's
not too difficult and you get just what you need. I would release my source code if my work contract allowed
it. I can outline details if anyone wants them.

Regards,
Michael Erskine
Kaspar Fischer | 2 May 16:53 2009
Picon

Log file per thread

Dear list,

I am looking for a way to create a log file per thread (actually, per  
Quartz job that gets run).

I've googled quite a bit and found a few approaches, in particular  
KeyFileAppender [1]. All I have seen seem to rely on the MDC and  
KeyFileAppender seems to have a resource leak [2].

I am wondering whether there is a simply way to programmatically  
create, at the beginning of my thread, a logger with a given name and  
closing it at the end of the thread. Has anybody accomplished  
something like this?

   public void run()
   {
      String id = ...; // thread name or whatever
      Logger logger = ...; // Create a logger with a basename and the id
      try
      {
        // ...
      }
      finally
      {
        logger.close(); // Something like this is needed to make sure
                        // old logs do not keep hanging around
      }
   }

Many thanks,
(Continue reading)

Yair Ogen | 3 May 08:24 2009
Picon

Re: Log file per thread

Ho about creating a Logger in ThreadLocal with a unique name that is based
on the thread name?

On Sat, May 2, 2009 at 5:53 PM, Kaspar Fischer <fischerk <at> inf.ethz.ch> wrote:

> Dear list,
>
> I am looking for a way to create a log file per thread (actually, per
> Quartz job that gets run).
>
> I've googled quite a bit and found a few approaches, in particular
> KeyFileAppender [1]. All I have seen seem to rely on the MDC and
> KeyFileAppender seems to have a resource leak [2].
>
> I am wondering whether there is a simply way to programmatically create, at
> the beginning of my thread, a logger with a given name and closing it at the
> end of the thread. Has anybody accomplished something like this?
>
>  public void run()
>  {
>     String id = ...; // thread name or whatever
>     Logger logger = ...; // Create a logger with a basename and the id
>     try
>     {
>       // ...
>     }
>     finally
>     {
>       logger.close(); // Something like this is needed to make sure
>                       // old logs do not keep hanging around
(Continue reading)

Kaspar Fischer | 3 May 14:04 2009
Picon

Re: Log file per thread

Yair, first of all, thanks for your answer.

> Ho about creating a Logger in ThreadLocal with a unique name that is  
> based
> on the thread name?

Apologies for this basic question, but how can I do this?

Just passing a new name to getLogger()?

   http://logging.apache.org/log4j/1.2/apidocs/org/apache/log4j/Logger.html

More importantly, how can I dispose of the logger? Otherwise the  
number of
open loggers grows with the number of threads run.

Thanks,
Kaspar

> On Sat, May 2, 2009 at 5:53 PM, Kaspar Fischer  
> <fischerk <at> inf.ethz.ch> wrote:
>
>> Dear list,
>>
>> I am looking for a way to create a log file per thread (actually, per
>> Quartz job that gets run).
>>
>> I've googled quite a bit and found a few approaches, in particular
>> KeyFileAppender [1]. All I have seen seem to rely on the MDC and
>> KeyFileAppender seems to have a resource leak [2].
(Continue reading)

Yair Ogen | 3 May 16:43 2009
Picon

Re: Log file per thread

Hi,

I can't say I tried this myself but let's assume you have this code:

public void run()
{
  String id = ...; // thread name or whatever
  Logger logger = ...; // Create a logger with a basename and the id
  ThreadLocal<Logger> loggerThreadLocal = new ThreadLocal<Logger>();
  loggerThreadLocal.set(logger);
  try
  {
    // ...
    ((Logger)loggerThreadLocal.get()).info...
  }
  finally
  {
    // nothing here. when the thread dies the thread local is cleaned up for
you.
  }
}

well this is a pseudo of my idea. Again - haven't tried this...

good luck.

On Sun, May 3, 2009 at 3:04 PM, Kaspar Fischer <fischerk <at> inf.ethz.ch> wrote:

> Yair, first of all, thanks for your answer.
>
(Continue reading)

Jacob Kjome | 3 May 18:06 2009

Re: Log file per thread

What you have below does nothing for the file being appended to.  There have been
long discussions in the past, on this list, about a file per thread.  I believe
most have resorted to using a custom, thread-based, repository selector.  I
suggest research be done on what's been said before.

As far as disposing of loggers so they don't increase with the number of threads,
if they are named the same thing, then they get reused in the same logger
repository, so that wouldn't be an issue.  That is, assuming you found a way to
log to a different file/thread without resorting to a repository selector.

If you do use a repository selector, you'd probably have the issue of logger
repositories increasing as threads increase.  In that case, you'd probably need to
implement some logger repository disposal routine.

Jake

On 5/3/2009 8:43 AM, Yair Ogen wrote:
> Hi,
> 
> I can't say I tried this myself but let's assume you have this code:
> 
> public void run()
> {
>   String id = ...; // thread name or whatever
>   Logger logger = ...; // Create a logger with a basename and the id
>   ThreadLocal<Logger> loggerThreadLocal = new ThreadLocal<Logger>();
>   loggerThreadLocal.set(logger);
>   try
>   {
>     // ...
(Continue reading)

Bender Heri | 4 May 11:46 2009
Picon

AW: [SPAM (Bayesain Analysis)] - Log file per thread - Bayesian Filter detected spam

Log4j distinguishes between Loggers and Appenders for a good reason:
  - Loggers define WHAT is logged (level, source)
  - Appenders define WHERE the log statement goes (console, file, etc.) and how it is formatted
You want to have a new file for each new thread, so this is an appender issue which you cannot solve by creating
a new appender. 
Of course you can create a Logger as you suggested, but then you have to pass this logger instance along your
callstack (or make it globally accessible in the current thread context). If you do so you will loose most
of the benefits which log4j offers. You implement then something like your own logging framework, a thing
which to avoid was the main goal of inventing log4j.
Follow the suggestion of Jake Kjome to search after this discussions in this mailing list and implement
your RepositorySelector, based on MDC. There were even examples posted.
Heri

-----Ursprüngliche Nachricht-----
Von: Kaspar Fischer [mailto:fischerk <at> inf.ethz.ch] 
Gesendet: Samstag, 2. Mai 2009 16:54
An: log4j-user <at> logging.apache.org
Betreff: [SPAM (Bayesain Analysis)] - Log file per thread - Bayesian Filter detected spam

Dear list,

I am looking for a way to create a log file per thread (actually, per Quartz job that gets run).

I've googled quite a bit and found a few approaches, in particular KeyFileAppender [1]. All I have seen seem
to rely on the MDC and KeyFileAppender seems to have a resource leak [2].

I am wondering whether there is a simply way to programmatically create, at the beginning of my thread, a
logger with a given name and closing it at the end of the thread. Has anybody accomplished something like this?

   public void run()
(Continue reading)

JasDA | 4 May 14:56 2009
Picon

Access logfile logger

Hi,

I'm using log4j with a DailyRollingFileAppender. Now I want to add some reporting functions to the same
application that uses this appender. So I need to get access to the logfile that is written by the file
appender. Only the current logfile needs to be read so is is possible via the logger instance?

Logger logger = Logger.getLogger(this.class);

Regards,
Jason

______________________________________________________
GRATIS für alle WEB.DE-Nutzer: Die maxdome Movie-FLAT!
Jetzt freischalten unter http://movieflat.web.de
Yair Ogen | 4 May 15:28 2009
Picon

Re: Access logfile logger

I think the approach should be via the appender. you can try and extend it -
AFAIK only the appender can give you the file name.

On Mon, May 4, 2009 at 3:56 PM, <JasDA <at> web.de> wrote:

> Hi,
>
> I'm using log4j with a DailyRollingFileAppender. Now I want to add some
> reporting functions to the same application that uses this appender. So I
> need to get access to the logfile that is written by the file appender. Only
> the current logfile needs to be read so is is possible via the logger
> instance?
>
> Logger logger = Logger.getLogger(this.class);
>
> Regards,
> Jason
>
>
> ______________________________________________________
> GRATIS für alle WEB.DE-Nutzer: Die maxdome Movie-FLAT!
> Jetzt freischalten unter http://movieflat.web.de
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: log4j-user-unsubscribe <at> logging.apache.org
> For additional commands, e-mail: log4j-user-help <at> logging.apache.org
>
>
(Continue reading)


Gmane