{"id":21381,"date":"2023-01-05T13:31:52","date_gmt":"2023-01-05T12:31:52","guid":{"rendered":"https:\/\/www.dbi-services.com\/blog\/?p=21381"},"modified":"2024-09-11T10:25:46","modified_gmt":"2024-09-11T08:25:46","slug":"log-rotation-in-jboss-eap","status":"publish","type":"post","link":"https:\/\/www.dbi-services.com\/blog\/log-rotation-in-jboss-eap\/","title":{"rendered":"Log Rotation in JBoss-EAP"},"content":{"rendered":"\n<p>Log rotation is an important topic while configuring any software. If it is not tuned as it should it could lead to full partitions, service outages or even configuration corruptions.<br>JBoss-EAP is not different, thus I will explain what are our best practices.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">JBoss-EAP Log Rotation Capabilities<\/h2>\n\n\n\n<p>Out of the box, JBoss-EAP profiles are configured with two loggers:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>CONSOLE: Used to log when run from script directly<\/li>\n\n\n\n<li>FILE: Used to log into server.log<\/li>\n<\/ul>\n\n\n\n<p>FILE is configured with a suffix &#8220;.yyyy-MM-dd&#8221;. This indicate to JBoss-EAP to rotate it every day, at midnight.<\/p>\n\n\n\n<p>This is a good start, but it omits an important part: Purge of rotated log files.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Purging Log Files<\/h2>\n\n\n\n<p>There is another handler that is taking care of oldest rotated logs, <code>size-rotating-file-handler<\/code>, as explained in documentation:<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p>Defines a handler which writes to a file, rotating the log after the size of the file grows beyond a certain point and keeping a fixed number of backups.<\/p>\n<\/blockquote>\n\n\n\n<p>This is nice, but as log files are rotated based on size and not on time, this will make search painful. So we have to find another option.<\/p>\n\n\n\n<p>Nevertheless, here is an example of jboss-cli command to set it:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&#091;standalone@192.168.1.10:9990 \/] \/subsystem=logging\/size-rotating-file-handler=SRFH:add(named-formatter=COLOR-PATTERN,file={\"path\"=&gt;\"server3.log\",\"relative-to\"=&gt;\"jboss.server.log.dir\"},append=true,autoflush=true,level=INFO)\n{\"outcome\" : \"success\"}<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">External Log Rotation<\/h2>\n\n\n\n<p>As <code>logrotate <\/code>is available on all main Linux distributions, we will go for that option. This is as simple as creating a file in <code>\/etc\/logrotate.d\/<\/code> with following content:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n\/data\/JBoss-EAP\/log\/*.log {\n        daily\n        missingok\n        rotate 30\n        dateext\n        compress\n        delaycompress\n        notifempty\n        copytruncate\n}\n<\/pre><\/div>\n\n\n<p>Here are the meaning of each line:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>daily<\/code>: All .log files are rotated<\/li>\n\n\n\n<li><code>missingok<\/code>: Missing file is ignored. Next file will be processed.<\/li>\n\n\n\n<li>rotate: Keeping 30 days.\n<ul class=\"wp-block-list\">\n<li>This could be decreased based on available disk space and verbosity.<\/li>\n\n\n\n<li>This could be increased, for example, for regulatory needs.<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><code>dateext <\/code>adds date to the rotated log file instead of a simple index. This will make search in logs easier.<\/li>\n\n\n\n<li><code>compress <\/code>rotated log files.<\/li>\n\n\n\n<li>delay that compression by one rotation cycle. The next day, in configuration above. This also makes search easier as if I am looking for a log in previous day, I don&#8217;t need to uncompress the rotated file.<\/li>\n\n\n\n<li><code>notifempty <\/code>will prevent empty file rotation.<\/li>\n\n\n\n<li><code>copytruncate <\/code>will keep existing file handler is the safest way to rotate log file.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">What About Access Logs?<\/h2>\n\n\n\n<p>access log is not enabled by default. Enabling it is just one command:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/subsystem=undertow\/server=default-server\/host=default-host\/setting=access-log:add(pattern=\"%h %l %u %t \\\"%r\\\" %s %b \\\"%{i,Referer}\\\" \\\"%{i,User-Agent}\\\" Cookie: \\\"%{i,COOKIE}\\\" Set-Cookie: \\\"%{o,SET-COOKIE}\\\" SessionID: %S Thread: \\\"%I\\\" TimeTaken: %T\",rotate=true)<\/code><\/pre>\n\n\n\n<p>As you might have seen, there is a rotate attribute which I set to true, but nothing indicates when it will occur. So, here is a small tip to have more information on a field: <code>read-resource-description<\/code><\/p>\n\n\n\n<p>This can be called by changing directory first or with absolute path:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/subsystem=undertow\/server=default-server\/host=default-host\/setting=access-log:read-resource-description<\/code><\/pre>\n\n\n\n<p>Here is a the section concerning rotate field:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>...\n\"rotate\" : {\n\t\"type\" : {\n\t\t\"TYPE_MODEL_VALUE\" : \"BOOLEAN\"\n\t},\n\t\"description\" : \"Rotate the access log every day.\",\n\t\"expressions-allowed\" : true,\n\t\"required\" : false,\n\t\"nillable\" : true,\n\t\"default\" : true,\n\t\"access-type\" : \"read-write\",\n\t\"storage\" : \"configuration\",\n\t\"restart-required\" : \"all-services\"\n},\n...<\/code><\/pre>\n\n\n\n<p>This means that we have very limited control on how access logs are rotated. For example, hourly rotation is not possible.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Outcome<\/h2>\n\n\n\n<p>Despite JBoss-EAP log rotation options, it is highly recommended to delegate log rotation and purge to an external tool like logrotate because JBoss-EAP:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Can not manage time named files and purge with one file handler<\/li>\n\n\n\n<li>Can not rotate access log files beside daily rotation<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>Log rotation is an important topic while configuring any software. If it is not tuned as it should it could lead to full partitions, service outages or even configuration corruptions.JBoss-EAP is not different, thus I will explain what are our best practices. JBoss-EAP Log Rotation Capabilities Out of the box, JBoss-EAP profiles are configured with [&hellip;]<\/p>\n","protected":false},"author":40,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[197],"tags":[119,1100],"type_dbi":[],"class_list":["post-21381","post","type-post","status-publish","format-standard","hentry","category-application-integration-middleware","tag-jboss-eap","tag-wildfly"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v27.2 (Yoast SEO v27.2) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>Log Rotation in JBoss-EAP - dbi Blog<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.dbi-services.com\/blog\/log-rotation-in-jboss-eap\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Log Rotation in JBoss-EAP\" \/>\n<meta property=\"og:description\" content=\"Log rotation is an important topic while configuring any software. If it is not tuned as it should it could lead to full partitions, service outages or even configuration corruptions.JBoss-EAP is not different, thus I will explain what are our best practices. JBoss-EAP Log Rotation Capabilities Out of the box, JBoss-EAP profiles are configured with [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.dbi-services.com\/blog\/log-rotation-in-jboss-eap\/\" \/>\n<meta property=\"og:site_name\" content=\"dbi Blog\" \/>\n<meta property=\"article:published_time\" content=\"2023-01-05T12:31:52+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-09-11T08:25:46+00:00\" \/>\n<meta name=\"author\" content=\"Middleware Team\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Middleware Team\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.dbi-services.com\/blog\/log-rotation-in-jboss-eap\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.dbi-services.com\/blog\/log-rotation-in-jboss-eap\/\"},\"author\":{\"name\":\"Middleware Team\",\"@id\":\"https:\/\/www.dbi-services.com\/blog\/#\/schema\/person\/8d8563acfc6e604cce6507f45bac0ea1\"},\"headline\":\"Log Rotation in JBoss-EAP\",\"datePublished\":\"2023-01-05T12:31:52+00:00\",\"dateModified\":\"2024-09-11T08:25:46+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.dbi-services.com\/blog\/log-rotation-in-jboss-eap\/\"},\"wordCount\":488,\"commentCount\":0,\"keywords\":[\"JBoss EAP\",\"WildFly\"],\"articleSection\":[\"Application integration &amp; Middleware\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.dbi-services.com\/blog\/log-rotation-in-jboss-eap\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.dbi-services.com\/blog\/log-rotation-in-jboss-eap\/\",\"url\":\"https:\/\/www.dbi-services.com\/blog\/log-rotation-in-jboss-eap\/\",\"name\":\"Log Rotation in JBoss-EAP - dbi Blog\",\"isPartOf\":{\"@id\":\"https:\/\/www.dbi-services.com\/blog\/#website\"},\"datePublished\":\"2023-01-05T12:31:52+00:00\",\"dateModified\":\"2024-09-11T08:25:46+00:00\",\"author\":{\"@id\":\"https:\/\/www.dbi-services.com\/blog\/#\/schema\/person\/8d8563acfc6e604cce6507f45bac0ea1\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.dbi-services.com\/blog\/log-rotation-in-jboss-eap\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.dbi-services.com\/blog\/log-rotation-in-jboss-eap\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.dbi-services.com\/blog\/log-rotation-in-jboss-eap\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Accueil\",\"item\":\"https:\/\/www.dbi-services.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Log Rotation in JBoss-EAP\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.dbi-services.com\/blog\/#website\",\"url\":\"https:\/\/www.dbi-services.com\/blog\/\",\"name\":\"dbi Blog\",\"description\":\"\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.dbi-services.com\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.dbi-services.com\/blog\/#\/schema\/person\/8d8563acfc6e604cce6507f45bac0ea1\",\"name\":\"Middleware Team\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/secure.gravatar.com\/avatar\/ddcae7ba0f9d1a0e7ae707f0e689e4a9c95bb48ec49c8e6d9cc86d43f4121cb6?s=96&d=mm&r=g\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/ddcae7ba0f9d1a0e7ae707f0e689e4a9c95bb48ec49c8e6d9cc86d43f4121cb6?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/ddcae7ba0f9d1a0e7ae707f0e689e4a9c95bb48ec49c8e6d9cc86d43f4121cb6?s=96&d=mm&r=g\",\"caption\":\"Middleware Team\"},\"url\":\"https:\/\/www.dbi-services.com\/blog\/author\/middleware-team\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Log Rotation in JBoss-EAP - dbi Blog","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.dbi-services.com\/blog\/log-rotation-in-jboss-eap\/","og_locale":"en_US","og_type":"article","og_title":"Log Rotation in JBoss-EAP","og_description":"Log rotation is an important topic while configuring any software. If it is not tuned as it should it could lead to full partitions, service outages or even configuration corruptions.JBoss-EAP is not different, thus I will explain what are our best practices. JBoss-EAP Log Rotation Capabilities Out of the box, JBoss-EAP profiles are configured with [&hellip;]","og_url":"https:\/\/www.dbi-services.com\/blog\/log-rotation-in-jboss-eap\/","og_site_name":"dbi Blog","article_published_time":"2023-01-05T12:31:52+00:00","article_modified_time":"2024-09-11T08:25:46+00:00","author":"Middleware Team","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Middleware Team","Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.dbi-services.com\/blog\/log-rotation-in-jboss-eap\/#article","isPartOf":{"@id":"https:\/\/www.dbi-services.com\/blog\/log-rotation-in-jboss-eap\/"},"author":{"name":"Middleware Team","@id":"https:\/\/www.dbi-services.com\/blog\/#\/schema\/person\/8d8563acfc6e604cce6507f45bac0ea1"},"headline":"Log Rotation in JBoss-EAP","datePublished":"2023-01-05T12:31:52+00:00","dateModified":"2024-09-11T08:25:46+00:00","mainEntityOfPage":{"@id":"https:\/\/www.dbi-services.com\/blog\/log-rotation-in-jboss-eap\/"},"wordCount":488,"commentCount":0,"keywords":["JBoss EAP","WildFly"],"articleSection":["Application integration &amp; Middleware"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.dbi-services.com\/blog\/log-rotation-in-jboss-eap\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.dbi-services.com\/blog\/log-rotation-in-jboss-eap\/","url":"https:\/\/www.dbi-services.com\/blog\/log-rotation-in-jboss-eap\/","name":"Log Rotation in JBoss-EAP - dbi Blog","isPartOf":{"@id":"https:\/\/www.dbi-services.com\/blog\/#website"},"datePublished":"2023-01-05T12:31:52+00:00","dateModified":"2024-09-11T08:25:46+00:00","author":{"@id":"https:\/\/www.dbi-services.com\/blog\/#\/schema\/person\/8d8563acfc6e604cce6507f45bac0ea1"},"breadcrumb":{"@id":"https:\/\/www.dbi-services.com\/blog\/log-rotation-in-jboss-eap\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.dbi-services.com\/blog\/log-rotation-in-jboss-eap\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.dbi-services.com\/blog\/log-rotation-in-jboss-eap\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Accueil","item":"https:\/\/www.dbi-services.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Log Rotation in JBoss-EAP"}]},{"@type":"WebSite","@id":"https:\/\/www.dbi-services.com\/blog\/#website","url":"https:\/\/www.dbi-services.com\/blog\/","name":"dbi Blog","description":"","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.dbi-services.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/www.dbi-services.com\/blog\/#\/schema\/person\/8d8563acfc6e604cce6507f45bac0ea1","name":"Middleware Team","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/ddcae7ba0f9d1a0e7ae707f0e689e4a9c95bb48ec49c8e6d9cc86d43f4121cb6?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/ddcae7ba0f9d1a0e7ae707f0e689e4a9c95bb48ec49c8e6d9cc86d43f4121cb6?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/ddcae7ba0f9d1a0e7ae707f0e689e4a9c95bb48ec49c8e6d9cc86d43f4121cb6?s=96&d=mm&r=g","caption":"Middleware Team"},"url":"https:\/\/www.dbi-services.com\/blog\/author\/middleware-team\/"}]}},"_links":{"self":[{"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/posts\/21381","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/users\/40"}],"replies":[{"embeddable":true,"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/comments?post=21381"}],"version-history":[{"count":9,"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/posts\/21381\/revisions"}],"predecessor-version":[{"id":21442,"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/posts\/21381\/revisions\/21442"}],"wp:attachment":[{"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/media?parent=21381"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/categories?post=21381"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/tags?post=21381"},{"taxonomy":"type","embeddable":true,"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/type_dbi?post=21381"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}