You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-user@logging.apache.org by Jeff <jl...@gmail.com> on 2008/08/01 05:51:13 UTC

ConsoleAppender and closing an SSH session

I just converted some apps to log4j 1.2.15. The log4j config creates a
ConsoleAppender and a FileAppender as follows.

log4j.rootLogger=INFO,CONSOLE,WIPATH

log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender
log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout
log4j.appender.CONSOLE.layout.ConversionPattern=%d [%c{1}] %m%n

log4j.appender.WIPATH=org.apache.log4j.FileAppender
log4j.appender.WIPATH.File=/path/to/log/wipath.log
log4j.appender.WIPATH.layout=org.apache.log4j.PatternLayout
log4j.appender.WIPATH.layout.ConversionPattern=%d %-5p [%c{1}] %m%n

Normally these apps are launched from a serially connected character
terminal (think Wyse 50). The logging to console is there to make
non-techie users feel good and know that the application is running.

But if for some reason, I need to start the app from an SSH session
(putty), the application sometimes dies after I log out. Sometimes
right away, sometimes after some time has passed. Nothing about
interesting is written to the log file. Normally the app makes log
entries when it shuts down cleanly. The process is just gone. This did
not happen prior to implementing log4j. Previously, the app wrote to a
pre-configured file and to System.out. Closing an SSH session had no
ill effects.

OS is Linux, CentOS 4.6 32 bit under VMware Server 1.0.x. JRE is Sun
1.6.0_05-b13. There is no X display system installed.

I googled this without success. I'm hoping someone here has a clue for me.

-- 
Jeff

---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org


Re: ConsoleAppender and closing an SSH session

Posted by Thorbjørn Ravn Andersen <th...@gmail.com>.
Jeff skrev  den 01-08-2008 06:41:
> Well I'm not convinced that this is completely unrelated to log4j.
> This set of apps has run for 8 years in one form or another and has
> been scripted to survive a logout. Now, with no changes except the
> introduction of log4j, the behavior has changed.
>   
I agree with Paul that I don't think this is a log4j issue as such, but 
that the actions taken by log4j may trigger the shutdown (a filled 
buffer that cannot be written?  an error message with nowhere to go?)

My knee-jerk reaction is to ask if you use "nohup" when starting your 
program over ssh?  If not, could you elaborate on "has been scripted to 
survive a logout"?

--
  Thorbjørn

---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org


Re: ConsoleAppender and closing an SSH session

Posted by Paul Smith <ps...@aconex.com>.
>
> Well I'm not convinced that this is completely unrelated to log4j.
> This set of apps has run for 8 years in one form or another and has
> been scripted to survive a logout. Now, with no changes except the
> introduction of log4j, the behavior has changed.
>

In your configuration example, you're using ConsoleAppender and a  
file.  By default Console appender will just write to System.out print  
stream which is exactly what System.out.println() does, and the  
FileAppender is really pretty basic, I can't explain how log4j would  
affect the stability of the process..  Log4j has been in use for  
nearly as long as your app, so I'd be very surprised if log4j was  
proved to be the culprit.

Are you sure some operating system upgrade or configuration on the  
host itself has not enforced some process conditions that weren't  
there before?

> In any case, I appreciate the pointer to screen. I will check it out.

couldn't live without 'screen'.  one of the best pointers a sysadmin  
ever showed me (that and an awful lot of awk/sed).

Paul

---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org


Re: ConsoleAppender and closing an SSH session

Posted by Jeff <jl...@gmail.com>.
On Thu, Jul 31, 2008 at 11:11 PM, Paul Smith <ps...@aconex.com> wrote:
>>
>> But if for some reason, I need to start the app from an SSH session
>> (putty), the application sometimes dies after I log out. Sometimes
>> right away, sometimes after some time has passed. Nothing about
>> interesting is written to the log file. Normally the app makes log
>> entries when it shuts down cleanly. The process is just gone. This did
>> not happen prior to implementing log4j. Previously, the app wrote to a
>> pre-configured file and to System.out. Closing an SSH session had no
>> ill effects.
>>
>
> This is not really a logging question per-se, but I feel for you.  Unix
> process can die after the user shell that created them exits.  To be honest
> there doesn't appear to be a hard and fast rule as to this behaviour, but
> I'm quite confident it has nothing to do with log4j.  the 'nohup' unix
> command was originally designed for this purpose, but there's an even better
> way.
>
> Since you are launching a process that you want to stick around regardless
> of the connectivity of the shell process that launches it you should
> consider using the 'screen' application built into most *nix's.
>
> host> screen -S "Some Logical Name"
> host> /home/me/launchApp.sh
> ...
> .
> ..
>
> You can exit that terminal session at any time and it'll be safe from a hang
> up.  Even better, you can relogin and do:
>
> host> screen -ls
> There is a screen on:
>        23608.Some Logical Name (Attached)
> 1 Socket in /tmp/uscreens/S-psmith.
>
> you can then reconnect by:
>
> host> screen -r 23608
>
> or via other options (by name etc).
>
> 'screen' is fantastic when you're dealing with remote servers that you have
> problematic connections to (say, if they're on the other side of the world,
> which for me in Australia, is basically everything! :) ).  You can launch
> critical scripts knowing that a tcp disconnect will not cause any harm and
> you can come back to it later, even from a completely different computer.
>
> The authors of  'screen'  are definitely on my 'List of People To Buy Beers
> For".

Well I'm not convinced that this is completely unrelated to log4j.
This set of apps has run for 8 years in one form or another and has
been scripted to survive a logout. Now, with no changes except the
introduction of log4j, the behavior has changed.

In any case, I appreciate the pointer to screen. I will check it out.

-- 
Jeff

---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org


Re: ConsoleAppender and closing an SSH session

Posted by Paul Smith <ps...@aconex.com>.
>
> But if for some reason, I need to start the app from an SSH session
> (putty), the application sometimes dies after I log out. Sometimes
> right away, sometimes after some time has passed. Nothing about
> interesting is written to the log file. Normally the app makes log
> entries when it shuts down cleanly. The process is just gone. This did
> not happen prior to implementing log4j. Previously, the app wrote to a
> pre-configured file and to System.out. Closing an SSH session had no
> ill effects.
>

This is not really a logging question per-se, but I feel for you.   
Unix process can die after the user shell that created them exits.  To  
be honest there doesn't appear to be a hard and fast rule as to this  
behaviour, but I'm quite confident it has nothing to do with log4j.   
the 'nohup' unix command was originally designed for this purpose, but  
there's an even better way.

Since you are launching a process that you want to stick around  
regardless of the connectivity of the shell process that launches it  
you should consider using the 'screen' application built into most  
*nix's.

host> screen -S "Some Logical Name"
host> /home/me/launchApp.sh
...
.
..

You can exit that terminal session at any time and it'll be safe from  
a hang up.  Even better, you can relogin and do:

host> screen -ls
There is a screen on:
         23608.Some Logical Name (Attached)
1 Socket in /tmp/uscreens/S-psmith.

you can then reconnect by:

host> screen -r 23608

or via other options (by name etc).

'screen' is fantastic when you're dealing with remote servers that you  
have problematic connections to (say, if they're on the other side of  
the world, which for me in Australia, is basically everything! :) ).   
You can launch critical scripts knowing that a tcp disconnect will not  
cause any harm and you can come back to it later, even from a  
completely different computer.

The authors of  'screen'  are definitely on my 'List of People To Buy  
Beers For".

Paul


---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org