Win a copy of Functional Design and Architecture this week in the Functional programming forum!
  • 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
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

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: 24283
167
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?
 
To avoid criticism do nothing, say nothing, be nothing. -Elbert Hubbard. Please critique this tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
reply
    Bookmark Topic Watch Topic
  • New Topic