• 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

Restarting Tomcat Service purge the logs

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

I have Tomcat 7 configured to run as Windows Service. I am using SLF4J for logging. Logs are getting captured properly.
Only problem I have is when I restart Tomcat Service it purge the old logs, even if .

It seems this is Tomcat's default behavior when running as Windows Service.

Is it possible to change this behavior, I want whenever service gets restarted, it just append the new logs, instead of purging the old logs.

Thanks in advance.
 
Sheriff
Posts: 10445
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Which exact log files are you referring to?
 
Ravinderjit Singh
Ranch Hand
Posts: 78
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Log file which I mentioned in log4j file appender "server.log"

 
Jaikiran Pai
Sheriff
Posts: 10445
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I don't see why it would clean up the contents of the server.log file with the "append" set to true. Are you sure that's the only appender which refers to that server.log file? Maybe you have another configuration within that log4j file (or some other log4j configuration file which might be getting picked up) which has a different appender configuration for server.log?
 
Ravinderjit Singh
Ranch Hand
Posts: 78
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
These are the other appenders I have, but they don't refer to server.log file.

 
Ravinderjit Singh
Ranch Hand
Posts: 78
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Just for your information if that could help.
This behavior I see only when running Tomcat as Windows Service.
It works fine when using startup.bat file.
 
Jaikiran Pai
Sheriff
Posts: 10445
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
So when running as Windows Service how do you shutdown or restart the server? Does it shutdown/restart cleanly without any errors?
 
Ravinderjit Singh
Ranch Hand
Posts: 78
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am using Windows Services utility to start/stop/restart the Service.
There is no error on any action.
 
Ravinderjit Singh
Ranch Hand
Posts: 78
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This is what I have for that service.

set "PR_LOGPATH=%CATALINA_BASE%\var\log"
set "PR_LOGPREFIX=%SERVICE_NAME%"
set PR_STDOUTPUT=%CATALINA_BASE%\var\log\server.log
set PR_STDERROR=%CATALINA_BASE%\var\log\server.log
 
Jaikiran Pai
Sheriff
Posts: 10445
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Ravinderjit Singh wrote:
set PR_STDOUTPUT=%CATALINA_BASE%\var\log\server.log
set PR_STDERROR=%CATALINA_BASE%\var\log\server.log



How and where do those PR_STDOUTPUT and PR_STDERROR get used? Given the names of those variables, it's possible that whoever/wherever those are being used clears off the file contents during a restart.
 
Ravinderjit Singh
Ranch Hand
Posts: 78
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
These are the parameter which we need to define when configuring Tomcat as Windows Services as descried here
So most probably Tomcat must be using them, I am not using them in my application.
 
Jaikiran Pai
Sheriff
Posts: 10445
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
As is noted in that documentation:


--StdOutput Redirected stdout filename. If named auto then file is created inside LogPath with the name service-stdout.YEAR-MONTH-DAY.log.
--StdError Redirected stderr filename. If named auto then file is created inside LogPath with the name service-stderr.YEAR-MONTH-DAY.log.



I'm guessing that the script uses > to redirect instead of >> which is understandable for console/error stream redirection. My suggestion is you use different file(s) for the console/error stream logs. So change those 2 variables to something like:



 
Ravinderjit Singh
Ranch Hand
Posts: 78
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ok. I will try that.

Thanks for your suggestion.
 
You guys wanna see my fabulous new place? Or do you wanna look at this tiny ad?
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
reply
    Bookmark Topic Watch Topic
  • New Topic