Page 1 of 1

How to avoid subsonic.log being cleared at restart?

PostPosted: Fri Aug 06, 2010 6:19 am
by Ravefiend
Every time one starts up Subsonic, it'll recreate the subsonic.log file. Is there any way to avoid this from happening as I want to keep a full log that continues after restarting it? Or maybe, even have a log file created using a timestamp in its filename so that that the previous one doesn't get lost.

PostPosted: Wed Aug 11, 2010 3:44 pm
by Kirk
As far as I know, there's no setting for this. I believe you could preserve the log file by having a cron job make a periodic backup of it (if you're on linux anyway). But this may not be perfect... might miss the tail end of some logs.

If your server is only going to be restarted BY YOU, you could add a line to /etc/init.d/subsonic that would make a copy of the log somewhere before restarting Subsonic...

Now, why do you want to save your Subsonic logs..? I mean they're interesting, but I don't know how pertinent they could possibly be to anything after a day or two anyway. lol.

Cheers,
Kirk

PostPosted: Wed Aug 18, 2010 6:01 am
by Ravefiend
Yeah there are surely alternative ways to keep a complete log of it. I'm just interested in it to keep track of what has been played during a longer period of time, etc so having some more data to analyze ... :wink:

PostPosted: Wed Aug 18, 2010 5:56 pm
by baaldemon
Are you at all familiar with java and maven. The change is easy enough to make if you are. Simply get the latest code from the repository and modify the file net/sourceforge/subsonic/Logger.java

Look for the getPrinWriter method and change the line:
writer = new PrintWriter(new FileWriter(getLogFile(), false, true);
Change the false to true. This tells the FileWriter to append to the file if it already exists.

Recompile the code and then deploy your new version of subsonic. Your log file will then simply be appended to rather than overwritten each time you restart the server.

PostPosted: Thu Aug 19, 2010 6:53 am
by Ravefiend
Not familiar to Maven but Java works for me yes.

Code: Select all
    private static synchronized PrintWriter getPrintWriter() throws IOException {
        if (writer == null) {
            writer = new PrintWriter(new FileWriter(getLogFile(), false), true);
        }
        return writer;
    }

I'll get that one changed to this:

Code: Select all
    private static synchronized PrintWriter getPrintWriter() throws IOException {
        if (writer == null) {
            writer = new PrintWriter(new FileWriter(getLogFile(), true), true);
        }
        return writer;
    }

Thanks a lot for the tip baaldemon!

PostPosted: Fri Aug 20, 2010 8:33 pm
by Kirk
Good tip... I haven't had a chance to look at Subsonic's source code yet, but this actually may be a quick change worth making.

Kirk

Re: How to avoid subsonic.log being cleared at restart?

PostPosted: Wed Nov 05, 2014 2:33 pm
by tohmy
Is this still the best way of doing this?
I`m looking at using Subsonic for our music library here at a music-school and I need to keep the log files