• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Can I have "log4j" and "java.util.logging" write to the same log file ?

 
Ranch Hand
Posts: 311
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I have 2 web-applications, running simultaniously (under tomcat if that matters).
1. One of the applications is directly using the log4j API (configured through file log4j.xml).
2. The other is directly using the java.util.logging API (configured thorugh file logging.properties).

My question:
can I have both applications write to the same output file, e.g. "c:/myLog.log" ?

Note I can't touch the existing applications code, especially not re-write them so as to use a common API (such as commons-logging).
I can only change the configuration files.

Basically, I could tell log4.xml to use a FileAppender to "c:/myLog.log",
and then tell logging.properties to use a similar FileHandler to "c:/myLog.log".
But I was afraid it would cause conflicts (it's 2 buffered streams writing to the same file, which is weird I think - at the very least, it would mess up the order of messages, e.g. see the beginning of a log4j message, then cut off in mid-sentence to some JUL message, then continue the log4j message...).

Thanks.
[ September 02, 2007: Message edited by: Sol Ma-Orn ]
 
Ranch Hand
Posts: 2308
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Why do you want to write logs to two different application in the same log file.You can configure appender in both the configuration files point to the same file.But I do not think that it would work as after a stream is opened the file may be locked and another stream might not be possible to that.

Have you tried it ? Is it working ?
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic