Bug 4246 - Winsw creates unmanaged stdout and stderr logs
Winsw creates unmanaged stdout and stderr logs
Status: NEW
Product: winsw
Classification: Unclassified
Component: source
PC Windows
: P5 major
: ---
Assigned To: Kohsuke Kawaguchi
Depends on:
  Show dependency treegraph
Reported: 2011-05-24 13:04 UTC by dbritton
Modified: 2011-10-27 17:57 UTC (History)
4 users (show)

See Also:

Proposed patch for bug 4246 (4.42 KB, application/octet-stream)
2011-05-25 21:07 UTC, jstarrett
Addition of more log appenders (26.41 KB, patch)
2011-10-27 02:51 UTC, ryan.lea
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description dbritton 2011-05-24 13:04:55 UTC
When I install glassfish v3.1 as a windows service via
asadmin create-service --name name domain_name (winsw)
two unmanaged logfiles are created in glassfisn3/glassfish/domains/domain_name/bin/, called servcieName.err.log and serviceName.out.log. 

There is currently no method to tell winsw to not create the stdout/stderr log files.  They only seem to be managed on start up of the service.  If the service is up and running for a long time these files can get very big.  For glassfish v3.1, what we need , is a way to tell the service to not write ANYTHING to those log files. It is just a duplicate of what's going into the server log anyways.

BTW I configured the <logmode> to rotate and the files seem to continue to grow.
reset mode only takes place on service start-up.

Originally discussed on www.java.net forums

Comment 1 dbritton 2011-05-24 13:26:06 UTC
I just noticed that the <logmode>rotate is invalid.  I changed the mode to "roll" and restarted the service.  The log file was rolled to .old.  If the number of ".old" files are limited, I'm all set.
Comment 2 dbritton 2011-05-24 13:36:15 UTC
It looks like the roll logmode only works at service start-up also :(
Comment 3 jstarrett 2011-05-25 21:07:44 UTC
Created attachment 480 [details]
Proposed patch for bug 4246
Comment 4 jstarrett 2011-05-25 21:08:23 UTC
I am not a winsw developer, but I made the following changes to Main.cs in order to meet the needs of my current project involving Glassfish 3.0 and JavaDB.

- Expand environment variables for xml node "//logpath"
- Try / catch around "//stopexecutable" xml node lookup. Don't crash when non-existent
- Limit log file size based on new xml node "//logfilemaxsize". After this size reached, log files are either rotated (Logmode rotate), or further output is not captured to file (end thread CopyStream(..))
Comment 5 ryan.lea 2011-10-27 02:51:57 UTC
Created attachment 508 [details]
Addition of more log appenders

In a similar vein to the previous patch, but replaces the existing logmode with logAppenders.

The following appenders are supported:

Default - behaves the same as logmode = default
Used when no logAppender is specified

Reset - behaves the same as logmode = reset
<logAppender type="reset"/>

Rolling - behaves the same as logmode = roll
<logAppender type="rolling"/>

SizeBasedRolling - configurable size and number of files to keep
<logAppender type="rolling">
  <sizeThreshold>1</sizeThreshold> <-- in kB -->
  <keepFiles>2</keepFiles> <!-- number of files to keep when rolling over -->

TimeBasedRolling - pattern time based rolling
<logAppender type="rolling">
  <pattern>yyyy-MM-dd_HH-mm-ss</pattern> <!-- time format to use -->
  <period>120</period> <!-- how often to roll over - based upon smallest unit of time from the pattern.  In this example, it would roll every 120 seconds. --> 
Comment 6 ryan.lea 2011-10-27 02:53:20 UTC
My patch also adds an attribute to the argument tag, qws (quote whitespace), which allows for overrides of the default to quote whitespace.
Comment 7 kohsukekawaguchi 2011-10-27 17:57:47 UTC
Applied the patch with some changes. Note that the code is moved to GitHub: http://github.com/kohsuke/winsw