• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Rob Spoor
  • Henry Wong
  • Liutauras Vilda
Saloon Keepers:
  • Tim Moores
  • Carey Brown
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
Bartenders:
  • Frits Walraven
  • Himai Minh
  • Jj Roberts

Catalina.out logs in TomCat 9 in JSON format

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello

Please tell me how to keep catalina.out logs in TomCat 9 in JSON format (you can transfer them to another file, for example 1234. log, but in JSON format)

It is necessary to add the static parameter "Program":"Tomcat" to each JSON line-so it is necessary

thanks
 
Saloon Keeper
Posts: 23409
159
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to the Ranch, Tom!

The catalina.out log is not a true log. It's a redirection of the JVM's stdout and stderr data streams to that file. And in fact, a few Tomcat configurations don't even do that.

Tomcat itself logs by default using the JULI logger (java.util.Logging Interface), but it is possible to use an alternative logger. You have to do a custom build of Tomcat, however - its not a configurable option.

I don't guarantee that everything that goes to catalina.out will be properly log-formatted, however, since the log is being written to a standard I/O stream. So any random System.out.println's for example would not go through the logger, nor would the catastropic case where the JVM itself dies and dumps diagnostic information (though we hope not to ever see that!)

You could modify the catalina.bat/catalina.sh scripts to prefix all lines in catalina.out. I'm not sure of an easy way to do that for Windows, but Unix-style OS's could pipe the stdio streams through the sed utility and let sed prefix each line as it is written.

I should note - because, alas the Tomcat docs don't make it obvious - that catalina.out logs only for the Tomcat program itself. The webapps are each responsible for their own logging and can use whatever logger they want.
 
Tom Crous
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
People, who set up FluentD or LogStash for this task?
 
All of life is a contant education - Eleanor Roosevelt. Tiny ad:
SKIP - a book about connecting industrious people with elderly land owners
https://coderanch.com/t/skip-book
reply
    Bookmark Topic Watch Topic
  • New Topic