{"id":1470,"date":"2015-09-16T08:55:51","date_gmt":"2015-09-16T15:55:51","guid":{"rendered":"http:\/\/10kdev.net\/?p=1470"},"modified":"2015-09-16T08:57:01","modified_gmt":"2015-09-16T15:57:01","slug":"large-grails-log-file","status":"publish","type":"post","link":"http:\/\/10kdev.net\/?p=1470","title":{"rendered":"Large Grails Log File"},"content":{"rendered":"<div style=\"width: 250px\" class=\"wp-caption aligncenter\"><img decoding=\"async\" loading=\"lazy\" src=\"http:\/\/10kdev.net\/wp-content\/uploads\/2015\/09\/8b0798df1a711ccb59cc46e5f0f9c58b.png\" alt=\"\" width=\"240\" height=\"180\" \/><p class=\"wp-caption-text\">Where are you tiny tiny huge file?<\/p><\/div>\n<p>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&#8217;t want to lose so re-cloning wasn&#8217;t an option. Much to my surprise, when I got info on the entire repo directory it was almost 28 gigabytes.<\/p>\n<p><span style=\"line-height: 1.5;\">My first check was to see if the .git directories, any project directories (for IntelliJ and Eclipse) and any roaming maven directories mightin&#8217; be largin&#8217; up my projects. No, those were not the cause for concern.<\/span><\/p>\n<p>I finally ran a search (<code>find ~ -size +10G<\/code>) for some huge\u00a0files and found what I was looking for in the grails \/target directory of one of the projects.<\/p>\n<p><img decoding=\"async\" class=\" aligncenter\" src=\"http:\/\/10kdev.net\/wp-content\/uploads\/2015\/09\/36dc51453776b5d342bd5846f6c54965.png\" alt=\"\" \/><\/p>\n<p>Searching through Config.groovy &#8212; the log4j config entry didn&#8217;t have a file size limit set. \u00a0Maybe 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.<\/p>\n<p><a href=\"http:\/\/stackoverflow.com\/a\/15848829\/925530\">An\u00a0answer for managing log4j file size is here in stackoverflow<\/a>:<\/p>\n<p style=\"padding-left: 30px;\">You can control this in <a href=\"http:\/\/grails.org\/doc\/latest\/guide\/conf.html#logging\">the <code>log4j<\/code> DSL<\/a> in <code>Config.groovy<\/code>, under the <code>appenders<\/code> block. The default behaviour is equivalent to an appender definition of<\/p>\n<pre class=\"default prettyprint prettyprinted\" style=\"padding-left: 30px;\"><code><span class=\"pln\">file name<\/span><span class=\"pun\">:<\/span><span class=\"str\">'stacktrace'<\/span><span class=\"pun\">,<\/span><span class=\"pln\"> file<\/span><span class=\"pun\">:<\/span><span class=\"str\">'stacktrace.log`<\/span><\/code><\/pre>\n<p style=\"padding-left: 30px;\">in prod mode and <code>file:'target\/stacktrace.log'<\/code> in dev mode, you could replace it with e.g.<\/p>\n<pre class=\"default prettyprint prettyprinted\" style=\"padding-left: 30px;\"><code><span class=\"pln\">rollingFile name<\/span><span class=\"pun\">:<\/span><span class=\"str\">'stacktrace'<\/span><span class=\"pun\">,<\/span><span class=\"pln\"> file<\/span><span class=\"pun\">:<\/span><span class=\"str\">'stacktrace.log'<\/span><span class=\"pun\">,<\/span><span class=\"pln\">\r\n    maxFileSize<\/span><span class=\"pun\">:<\/span><span class=\"str\">'5MB'<\/span><span class=\"pun\">,<\/span><span class=\"pln\"> maxBackupIndex<\/span><span class=\"pun\">:<\/span><span class=\"lit\">2<\/span><\/code><\/pre>\n<p style=\"padding-left: 30px;\">to limit it to 15MB (the active file plus up to two rolled-over backups).<\/p>\n<p>I didn&#8217;t see an entry like that in our config. \u00a0Also, it may be our servers monitor and parse these files as usually log files off the developers&#8217; machines are not considered &#8220;ours.&#8221; \u00a0This is falling through the cracks and has to be fixed, imho, for the local dev settings.<\/p>\n<hr \/>\n<p>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. \u00a0Logback, and not log4j, is teh mechanism moving forward. \u00a0The manual says:<\/p>\n<p style=\"padding-left: 30px;\"><em>By default logging in Grails 3.0 is handled by the <a href=\"http:\/\/logback.qos.ch\" target=\"blank\">Logback logging framework<\/a> and can be configured with the <code>grails-app\/conf\/logback.groovy<\/code> file.<\/em><\/p>\n","protected":false},"excerpt":{"rendered":"<p>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&#8217;t want to lose so re-cloning wasn&#8217;t an option. Much to my surprise, when I got info on the entire repo directory it was almost 28 gigabytes. My first check [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[69,82,24],"tags":[83,33,80,84],"_links":{"self":[{"href":"http:\/\/10kdev.net\/index.php?rest_route=\/wp\/v2\/posts\/1470"}],"collection":[{"href":"http:\/\/10kdev.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/10kdev.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/10kdev.net\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/10kdev.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1470"}],"version-history":[{"count":3,"href":"http:\/\/10kdev.net\/index.php?rest_route=\/wp\/v2\/posts\/1470\/revisions"}],"predecessor-version":[{"id":1473,"href":"http:\/\/10kdev.net\/index.php?rest_route=\/wp\/v2\/posts\/1470\/revisions\/1473"}],"wp:attachment":[{"href":"http:\/\/10kdev.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1470"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/10kdev.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1470"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/10kdev.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1470"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}