[daemon] How to achieve log rotation of jsvc outside of Tomcat

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

[daemon] How to achieve log rotation of jsvc outside of Tomcat

Steve Cohen
I am using jsvc to run a non-Tomcat java application as a daemon.

I would like to achieve rotation of the system.out and system.err logs.  
This is running on a Linux system, but I am by no means a Linux guru and
when I see information like "support proper log rotation using SIGUSR1"
I don't know what that means.

Can someone provide a pointer to a more basic explanation for how to
keep these logs rotated?

Thanks.

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: [daemon] How to achieve log rotation of jsvc outside of Tomcat

Simon Kitching
Steve Cohen schrieb:
> I am using jsvc to run a non-Tomcat java application as a daemon.
>
> I would like to achieve rotation of the system.out and system.err
> logs.  This is running on a Linux system, but I am by no means a Linux
> guru and when I see information like "support proper log rotation
> using SIGUSR1" I don't know what that means.
>
> Can someone provide a pointer to a more basic explanation for how to
> keep these logs rotated?
I'm not a commons-daemon developer, but took a quick look anyway.

I guess your comment about "rotation using SIGUSR1" is referring to this
jira issue:
  http://issues.apache.org/jira/browse/DAEMON-95

That issue is still open, so as far as I can see jsvc does NOT support
this.

I can't see any other hint that jsvc supports log rotation, other than
stopping and restarting the service.

Note that a well-designed java app should not be writing much to stdout
or stderr, so log rotation for that shouldn't be all that important. If
you are getting lots of logging output, maybe the logging configuration
for the application itself is misconfigured? Most java apps use either
log4j, logback or java.util.logging's default loggers to write messages
and those can all be configured in various ways.

Regards,
Simon

--
-- Emails in "mixed" posting style will be ignored
-- (http://en.wikipedia.org/wiki/Posting_style)


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: [daemon] How to achieve log rotation of jsvc outside of Tomcat

Steve Cohen
Simon Kitching wrote:

> Steve Cohen schrieb:
>  
>> I am using jsvc to run a non-Tomcat java application as a daemon.
>>
>> I would like to achieve rotation of the system.out and system.err
>> logs.  This is running on a Linux system, but I am by no means a Linux
>> guru and when I see information like "support proper log rotation
>> using SIGUSR1" I don't know what that means.
>>
>> Can someone provide a pointer to a more basic explanation for how to
>> keep these logs rotated?
>>    
> I'm not a commons-daemon developer, but took a quick look anyway.
>
> I guess your comment about "rotation using SIGUSR1" is referring to this
> jira issue:
>   http://issues.apache.org/jira/browse/DAEMON-95
>
> That issue is still open, so as far as I can see jsvc does NOT support
> this.
>
> I can't see any other hint that jsvc supports log rotation, other than
> stopping and restarting the service.
>
> Note that a well-designed java app should not be writing much to stdout
> or stderr, so log rotation for that shouldn't be all that important. If
> you are getting lots of logging output, maybe the logging configuration
> for the application itself is misconfigured? Most java apps use either
> log4j, logback or java.util.logging's default loggers to write messages
> and those can all be configured in various ways.
>
> Regards,
> Simon
>
>  
I am using log4j.  Perhaps I need to turn off stdout logging.  But there
are still other things being written by support libraries that I've
never been able to figure out how to direct into log4j - Most notably
Hibernate, which logs the SQL to stdout and not to the log4j logs.  If I
could figure that out, this would get much less acute.

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: [daemon] How to achieve log rotation of jsvc outside of Tomcat

Simon Kitching
Steve Cohen schrieb:

> Simon Kitching wrote:
>> Steve Cohen schrieb:
>>  
>>> I am using jsvc to run a non-Tomcat java application as a daemon.
>>>
>>> I would like to achieve rotation of the system.out and system.err
>>> logs.  This is running on a Linux system, but I am by no means a Linux
>>> guru and when I see information like "support proper log rotation
>>> using SIGUSR1" I don't know what that means.
>>>
>>> Can someone provide a pointer to a more basic explanation for how to
>>> keep these logs rotated?
>>>    
>> I'm not a commons-daemon developer, but took a quick look anyway.
>>
>> I guess your comment about "rotation using SIGUSR1" is referring to this
>> jira issue:
>>   http://issues.apache.org/jira/browse/DAEMON-95
>>
>> That issue is still open, so as far as I can see jsvc does NOT support
>> this.
>>
>> I can't see any other hint that jsvc supports log rotation, other than
>> stopping and restarting the service.
>>
>> Note that a well-designed java app should not be writing much to stdout
>> or stderr, so log rotation for that shouldn't be all that important. If
>> you are getting lots of logging output, maybe the logging configuration
>> for the application itself is misconfigured? Most java apps use either
>> log4j, logback or java.util.logging's default loggers to write messages
>> and those can all be configured in various ways.
>>
>> Regards,
>> Simon
>>
>>  
> I am using log4j.  Perhaps I need to turn off stdout logging.  But
> there are still other things being written by support libraries that
> I've never been able to figure out how to direct into log4j - Most
> notably Hibernate, which logs the SQL to stdout and not to the log4j
> logs.  If I could figure that out, this would get much less acute.
I'm a little surprised that you have Hibernate SQL logging enabled in
what sounds like a production system (dev systems wouldn't be be running
as a service using jsvc).

But if Hibernate logging always writes to stdout then yes that is a problem.

It does sound like you should add a "me too" note to that JIRA issue in
case that pushes someone to commit the patch (or DAEMON-80 which uses
syslog instead). Until then maybe you should build your own version of
jsvc with that patch applied. Then you could have a cron script that does:
* mv system.out system.out.old
* kill -s SIGUSR1 pidOfJsvc (force jsvc to reopen logfiles, ie create
new system.out)
* wait a few seconds, or until file "system.out" is created
* now can safely move system.out.old to somewhere else

Cheers,
Simon


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: [daemon] How to achieve log rotation of jsvc outside of Tomcat

Simon Kitching
Simon Kitching schrieb:

> Steve Cohen schrieb:
>  
>> Simon Kitching wrote:
>>    
>>> Steve Cohen schrieb:
>>>  
>>>      
>>>> I am using jsvc to run a non-Tomcat java application as a daemon.
>>>>
>>>> I would like to achieve rotation of the system.out and system.err
>>>> logs.  This is running on a Linux system, but I am by no means a Linux
>>>> guru and when I see information like "support proper log rotation
>>>> using SIGUSR1" I don't know what that means.
>>>>
>>>> Can someone provide a pointer to a more basic explanation for how to
>>>> keep these logs rotated?
>>>>    
>>>>        
>>> I'm not a commons-daemon developer, but took a quick look anyway.
>>>
>>> I guess your comment about "rotation using SIGUSR1" is referring to this
>>> jira issue:
>>>   http://issues.apache.org/jira/browse/DAEMON-95
>>>
>>> That issue is still open, so as far as I can see jsvc does NOT support
>>> this.
>>>
>>> I can't see any other hint that jsvc supports log rotation, other than
>>> stopping and restarting the service.
>>>
>>> Note that a well-designed java app should not be writing much to stdout
>>> or stderr, so log rotation for that shouldn't be all that important. If
>>> you are getting lots of logging output, maybe the logging configuration
>>> for the application itself is misconfigured? Most java apps use either
>>> log4j, logback or java.util.logging's default loggers to write messages
>>> and those can all be configured in various ways.
>>>
>>> Regards,
>>> Simon
>>>
>>>  
>>>      
>> I am using log4j.  Perhaps I need to turn off stdout logging.  But
>> there are still other things being written by support libraries that
>> I've never been able to figure out how to direct into log4j - Most
>> notably Hibernate, which logs the SQL to stdout and not to the log4j
>> logs.  If I could figure that out, this would get much less acute.
>>    
> I'm a little surprised that you have Hibernate SQL logging enabled in
> what sounds like a production system (dev systems wouldn't be be running
> as a service using jsvc).
>
> But if Hibernate logging always writes to stdout then yes that is a problem.
>
> It does sound like you should add a "me too" note to that JIRA issue in
> case that pushes someone to commit the patch (or DAEMON-80 which uses
> syslog instead). Until then maybe you should build your own version of
> jsvc with that patch applied. Then you could have a cron script that does:
> * mv system.out system.out.old
> * kill -s SIGUSR1 pidOfJsvc (force jsvc to reopen logfiles, ie create
> new system.out)
> * wait a few seconds, or until file "system.out" is created
> * now can safely move system.out.old to somewhere else
>  

Hmm..just coincidentally, there is a thread on the tomcat-users list
about rotating the "catalina.out" logfile for tomcat. Someone suggested
a solution that might just work for you too. The suggestion was:

* create a unix pipe called something like "system.out"
* use the pipe as the file for jsvc to write to
* use program "rotatelogs" or "gzlogs" to read from the pipe.

These programs apparently are part of apache-httpd. I hadn't heard of
them before but googling shows plenty of info.

See the thread titled "catalina.out rotation" on tomcat-user for the
full info.

I'm a little worried about what happens if "rotatelogs" isn't running.
Presumably when the pipe is full the writer (ie jsvc) blocks. But it
probably isn't a problem in practice.

Regards,
Simon


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: [daemon] How to achieve log rotation of jsvc outside of Tomcat

Steve Cohen
In reply to this post by Simon Kitching
Simon Kitching wrote:

> Steve Cohen schrieb:
>  
>> Simon Kitching wrote:
>>    
>>> Steve Cohen schrieb:
>>>  
>>>      
>>>> I am using jsvc to run a non-Tomcat java application as a daemon.
>>>>
>>>> I would like to achieve rotation of the system.out and system.err
>>>> logs.  This is running on a Linux system, but I am by no means a Linux
>>>> guru and when I see information like "support proper log rotation
>>>> using SIGUSR1" I don't know what that means.
>>>>
>>>> Can someone provide a pointer to a more basic explanation for how to
>>>> keep these logs rotated?
>>>>    
>>>>        
>>> I'm not a commons-daemon developer, but took a quick look anyway.
>>>
>>> I guess your comment about "rotation using SIGUSR1" is referring to this
>>> jira issue:
>>>   http://issues.apache.org/jira/browse/DAEMON-95
>>>
>>> That issue is still open, so as far as I can see jsvc does NOT support
>>> this.
>>>
>>> I can't see any other hint that jsvc supports log rotation, other than
>>> stopping and restarting the service.
>>>
>>> Note that a well-designed java app should not be writing much to stdout
>>> or stderr, so log rotation for that shouldn't be all that important. If
>>> you are getting lots of logging output, maybe the logging configuration
>>> for the application itself is misconfigured? Most java apps use either
>>> log4j, logback or java.util.logging's default loggers to write messages
>>> and those can all be configured in various ways.
>>>
>>> Regards,
>>> Simon
>>>
>>>  
>>>      
>> I am using log4j.  Perhaps I need to turn off stdout logging.  But
>> there are still other things being written by support libraries that
>> I've never been able to figure out how to direct into log4j - Most
>> notably Hibernate, which logs the SQL to stdout and not to the log4j
>> logs.  If I could figure that out, this would get much less acute.
>>    
> I'm a little surprised that you have Hibernate SQL logging enabled in
> what sounds like a production system (dev systems wouldn't be be running
> as a service using jsvc).
>  
Good point about Hibernate logging in production.  On the other hand, we
run jsvc in development also, which was necessary to shake out our
experience using jsvc itself.  The logfile size is an issue in both.  In
any case, it's not a bad practice to make dev environment resemble
production as much as possible.
> But if Hibernate logging always writes to stdout then yes that is a problem.
>  
It doesn't, I'm sure, but I've never been able to get the control of it
that I wish.  One of these nagging issues one never has time to solve.

> It does sound like you should add a "me too" note to that JIRA issue in
> case that pushes someone to commit the patch (or DAEMON-80 which uses
> syslog instead). Until then maybe you should build your own version of
> jsvc with that patch applied. Then you could have a cron script that does:
> * mv system.out system.out.old
> * kill -s SIGUSR1 pidOfJsvc (force jsvc to reopen logfiles, ie create
> new system.out)
> * wait a few seconds, or until file "system.out" is created
> * now can safely move system.out.old to somewhere else
>
> Cheers,
> Simon
>
>  
Thanks.
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>
>
>  


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]