How to avoid subsonic.log being cleared at restart?

Need help? Post your questions here.

Moderator: moderators

How to avoid subsonic.log being cleared at restart?

Postby Ravefiend » Fri Aug 06, 2010 6:19 am

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.
Ravefiend
 
Posts: 7
Joined: Fri Jan 29, 2010 1:20 pm

Postby Kirk » Wed Aug 11, 2010 3:44 pm

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
Image
User avatar
Kirk
 
Posts: 310
Joined: Tue Jun 08, 2010 5:45 pm
Location: Illinois, USA

Postby Ravefiend » Wed Aug 18, 2010 6:01 am

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:
Ravefiend
 
Posts: 7
Joined: Fri Jan 29, 2010 1:20 pm

Postby baaldemon » Wed Aug 18, 2010 5:56 pm

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.
baaldemon
 
Posts: 99
Joined: Fri May 07, 2010 11:54 am

Postby Ravefiend » Thu Aug 19, 2010 6:53 am

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!
Ravefiend
 
Posts: 7
Joined: Fri Jan 29, 2010 1:20 pm

Postby Kirk » Fri Aug 20, 2010 8:33 pm

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
Image
User avatar
Kirk
 
Posts: 310
Joined: Tue Jun 08, 2010 5:45 pm
Location: Illinois, USA

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

Postby tohmy » Wed Nov 05, 2014 2:33 pm

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
tohmy
 
Posts: 1
Joined: Tue Nov 04, 2014 5:12 pm


Return to Help

Who is online

Users browsing this forum: No registered users and 22 guests