Large Grails Log File

Where are you tiny tiny huge file?

I was looking at reorganizing my directories for several grails and java projects I am on, and had local branches from our git hub I didn’t want to lose so re-cloning wasn’t an option. Much to my surprise, when I got info on the entire repo directory it was almost 28 gigabytes.

My first check was to see if the .git directories, any project directories (for IntelliJ and Eclipse) and any roaming maven directories mightin’ be largin’ up my projects. No, those were not the cause for concern.

I finally ran a search (find ~ -size +10G) for some huge files and found what I was looking for in the grails /target directory of one of the projects.

Searching through Config.groovy — the log4j config entry didn’t have a file size limit set.  Maybe for a development environment this is OK (um . . . 27 gigs?) but I like to repeat my settings, assigned or not, throughout all the environments to provide visual cues for the next person coming around to support the software.

An answer for managing log4j file size is here in stackoverflow:

You can control this in the log4j DSL in Config.groovy, under the appenders block. The default behaviour is equivalent to an appender definition of

file name:'stacktrace', file:'stacktrace.log`

in prod mode and file:'target/stacktrace.log' in dev mode, you could replace it with e.g.

rollingFile name:'stacktrace', file:'stacktrace.log',
    maxFileSize:'5MB', maxBackupIndex:2

to limit it to 15MB (the active file plus up to two rolled-over backups).

I didn’t see an entry like that in our config.  Also, it may be our servers monitor and parse these files as usually log files off the developers’ machines are not considered “ours.”  This is falling through the cracks and has to be fixed, imho, for the local dev settings.


We are running log4j in our applications, but note that this is considered legacy now and to be entered on our tech backlog to fix.  Logback, and not log4j, is teh mechanism moving forward.  The manual says:

By default logging in Grails 3.0 is handled by the Logback logging framework and can be configured with the grails-app/conf/logback.groovy file.

, , ,

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>