blob: 5dea44f0c4f1856a6e88cf5a91722d92e7c834d8 [file] [log] [blame]
"use strict";(self.webpackChunk=self.webpackChunk||[]).push([[3434],{15680:(e,n,o)=>{o.d(n,{xA:()=>d,yg:()=>y});var r=o(96540);function t(e,n,o){return n in e?Object.defineProperty(e,n,{value:o,enumerable:!0,configurable:!0,writable:!0}):e[n]=o,e}function i(e,n){var o=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);n&&(r=r.filter((function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable}))),o.push.apply(o,r)}return o}function a(e){for(var n=1;n<arguments.length;n++){var o=null!=arguments[n]?arguments[n]:{};n%2?i(Object(o),!0).forEach((function(n){t(e,n,o[n])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(o)):i(Object(o)).forEach((function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(o,n))}))}return e}function l(e,n){if(null==e)return{};var o,r,t=function(e,n){if(null==e)return{};var o,r,t={},i=Object.keys(e);for(r=0;r<i.length;r++)o=i[r],n.indexOf(o)>=0||(t[o]=e[o]);return t}(e,n);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(r=0;r<i.length;r++)o=i[r],n.indexOf(o)>=0||Object.prototype.propertyIsEnumerable.call(e,o)&&(t[o]=e[o])}return t}var s=r.createContext({}),g=function(e){var n=r.useContext(s),o=n;return e&&(o="function"==typeof e?e(n):a(a({},n),e)),o},d=function(e){var n=g(e.components);return r.createElement(s.Provider,{value:n},e.children)},c="mdxType",p={inlineCode:"code",wrapper:function(e){var n=e.children;return r.createElement(r.Fragment,{},n)}},u=r.forwardRef((function(e,n){var o=e.components,t=e.mdxType,i=e.originalType,s=e.parentName,d=l(e,["components","mdxType","originalType","parentName"]),c=g(o),u=t,y=c["".concat(s,".").concat(u)]||c[u]||p[u]||i;return o?r.createElement(y,a(a({ref:n},d),{},{components:o})):r.createElement(y,a({ref:n},d))}));function y(e,n){var o=arguments,t=n&&n.mdxType;if("string"==typeof e||t){var i=o.length,a=new Array(i);a[0]=u;var l={};for(var s in n)hasOwnProperty.call(n,s)&&(l[s]=n[s]);l.originalType=e,l[c]="string"==typeof e?e:t,a[1]=l;for(var g=2;g<i;g++)a[g]=o[g];return r.createElement.apply(null,a)}return r.createElement.apply(null,o)}u.displayName="MDXCreateElement"},35030:(e,n,o)=>{o.r(n),o.d(n,{assets:()=>d,contentTitle:()=>s,default:()=>y,frontMatter:()=>l,metadata:()=>g,toc:()=>c});var r=o(58168),t=o(98587),i=(o(96540),o(15680)),a=["components"],l={id:"logging",title:"Logging"},s=void 0,g={unversionedId:"configuration/logging",id:"configuration/logging",title:"Logging",description:"\x3c!--",source:"@site/docs/29.0.0/configuration/logging.md",sourceDirName:"configuration",slug:"/configuration/logging",permalink:"/docs/29.0.0/configuration/logging",draft:!1,tags:[],version:"current",frontMatter:{id:"logging",title:"Logging"},sidebar:"docs",previous:{title:"Extensions",permalink:"/docs/29.0.0/configuration/extensions"},next:{title:"Web console",permalink:"/docs/29.0.0/operations/web-console"}},d={},c=[{value:"Log directory",id:"log-directory",level:2},{value:"All-in-one start commands",id:"all-in-one-start-commands",level:2},{value:"Set the logs to asynchronously write",id:"set-the-logs-to-asynchronously-write",level:2}],p={toc:c},u="wrapper";function y(e){var n=e.components,o=(0,t.A)(e,a);return(0,i.yg)(u,(0,r.A)({},p,o,{components:n,mdxType:"MDXLayout"}),(0,i.yg)("p",null,"Apache Druid services emit logs that to help you debug.\nThe same services also emit periodic ",(0,i.yg)("a",{parentName:"p",href:"/docs/29.0.0/configuration/#enabling-metrics"},"metrics")," about their state.\nTo disable metric info logs set the following runtime property: ",(0,i.yg)("inlineCode",{parentName:"p"},"-Ddruid.emitter.logging.logLevel=debug"),"."),(0,i.yg)("p",null,"Druid uses ",(0,i.yg)("a",{parentName:"p",href:"http://logging.apache.org/log4j/2.x/"},"log4j2")," for logging.\nThe default configuration file log4j2.xml ships with Druid at the following path: ",(0,i.yg)("inlineCode",{parentName:"p"},"conf/druid/{config}/_common/log4j2.xml"),"."),(0,i.yg)("p",null,"By default, Druid uses ",(0,i.yg)("inlineCode",{parentName:"p"},"RollingRandomAccessFile")," for rollover daily, and keeps log files up to 7 days.\nIf that's not suitable in your case, modify the ",(0,i.yg)("inlineCode",{parentName:"p"},"log4j2.xml")," accordingly."),(0,i.yg)("p",null,"The following example log4j2.xml is based upon the micro quickstart:"),(0,i.yg)("pre",null,(0,i.yg)("code",{parentName:"pre"},'<?xml version="1.0" encoding="UTF-8" ?>\n<Configuration status="WARN">\n <Properties>\n \x3c!-- to change log directory, set DRUID_LOG_DIR environment variable to your directory before launching Druid --\x3e\n <Property name="druid.log.path" value="log" />\n </Properties>\n\n <Appenders>\n <Console name="Console" target="SYSTEM_OUT">\n <PatternLayout pattern="%d{ISO8601} %p [%t] %c -%notEmpty{ [%markerSimpleName]} %m%n"/>\n </Console>\n\n \x3c!-- Rolling Files--\x3e\n <RollingRandomAccessFile name="FileAppender"\n fileName="${sys:druid.log.path}/${sys:druid.node.type}.log"\n filePattern="${sys:druid.log.path}/${sys:druid.node.type}.%d{yyyyMMdd}.log">\n <PatternLayout pattern="%d{ISO8601} %p [%t] %c -%notEmpty{ [%markerSimpleName]} %m%n"/>\n <Policies>\n <TimeBasedTriggeringPolicy interval="1" modulate="true"/>\n </Policies>\n <DefaultRolloverStrategy>\n <Delete basePath="${sys:druid.log.path}/" maxDepth="1">\n <IfFileName glob="*.log" />\n <IfLastModified age="7d" />\n </Delete>\n </DefaultRolloverStrategy>\n </RollingRandomAccessFile>\n\n </Appenders>\n\n <Loggers>\n <Root level="info">\n <AppenderRef ref="FileAppender"/>\n </Root>\n\n \x3c!-- Set level="debug" to see stack traces for query errors --\x3e\n <Logger name="org.apache.druid.server.QueryResource" level="info" additivity="false">\n <Appender-ref ref="FileAppender"/>\n </Logger>\n <Logger name="org.apache.druid.server.QueryLifecycle" level="info" additivity="false">\n <Appender-ref ref="FileAppender"/>\n </Logger>\n\n \x3c!-- Set level="debug" or "trace" to see more Coordinator details (segment balancing, load/drop rules, etc) --\x3e\n <Logger name="org.apache.druid.server.coordinator" level="info" additivity="false">\n <Appender-ref ref="FileAppender"/>\n </Logger>\n\n \x3c!-- Set level="debug" to see low-level details about segments and ingestion --\x3e\n <Logger name="org.apache.druid.segment" level="info" additivity="false">\n <Appender-ref ref="FileAppender"/>\n </Logger>\n\n \x3c!-- Set level="debug" to see more information about extension initialization --\x3e\n <Logger name="org.apache.druid.initialization" level="info" additivity="false">\n <Appender-ref ref="FileAppender"/>\n </Logger>\n\n \x3c!-- Quieter logging at startup --\x3e\n <Logger name="org.skife.config" level="warn" additivity="false">\n <Appender-ref ref="FileAppender"/>\n </Logger>\n <Logger name="com.sun.jersey.guice" level="warn" additivity="false">\n <Appender-ref ref="FileAppender"/>\n </Logger>\n </Loggers>\n</Configuration>\n')),(0,i.yg)("p",null,"Peons always output logs to standard output. Middle Managers redirect task logs from standard output to\n",(0,i.yg)("a",{parentName:"p",href:"/docs/29.0.0/configuration/#log-long-term-storage"},"long-term storage"),"."),(0,i.yg)("admonition",{type:"info"},(0,i.yg)("p",{parentName:"admonition"}," NOTE:\nDruid shares the log4j configuration file among all services, including task peon processes.\nHowever, you must define a console appender in the logger for your peon processes.\nIf you don't define a console appender, Druid creates and configures a new console appender\nthat retains the log level, such as ",(0,i.yg)("inlineCode",{parentName:"p"},"info")," or ",(0,i.yg)("inlineCode",{parentName:"p"},"warn"),", but does not retain any other appender\nconfiguration, including non-console ones.")),(0,i.yg)("h2",{id:"log-directory"},"Log directory"),(0,i.yg)("p",null,"The included log4j2.xml configuration for Druid and ZooKeeper writes logs to the ",(0,i.yg)("inlineCode",{parentName:"p"},"log")," directory at the root of the distribution."),(0,i.yg)("p",null,"If you want to change the log directory, set the environment variable ",(0,i.yg)("inlineCode",{parentName:"p"},"DRUID_LOG_DIR")," to the right directory before you start Druid."),(0,i.yg)("h2",{id:"all-in-one-start-commands"},"All-in-one start commands"),(0,i.yg)("p",null,"If you use one of the all-in-one start commands, such as ",(0,i.yg)("inlineCode",{parentName:"p"},"bin/start-micro-quickstart"),", the default configuration for each service has two kinds of log files.\nLog4j2 writes the main log file and rotates it periodically.\nFor example, ",(0,i.yg)("inlineCode",{parentName:"p"},"log/historical.log"),"."),(0,i.yg)("p",null,"The secondary log file contains anything that is written by the component\ndirectly to standard output or standard error without going through log4j2.\nFor example, ",(0,i.yg)("inlineCode",{parentName:"p"},"log/historical.stdout.log"),".\nThis consists mainly of messages from the\nJava runtime itself.\nThis file is not rotated, but it is generally small due to the low volume of messages.\nIf necessary, you can truncate it using the Linux command ",(0,i.yg)("inlineCode",{parentName:"p"},"truncate --size 0 log/historical.stdout.log"),"."),(0,i.yg)("h2",{id:"set-the-logs-to-asynchronously-write"},"Set the logs to asynchronously write"),(0,i.yg)("p",null,"If your logs are really chatty, you can set them to write asynchronously.\nThe following example shows a ",(0,i.yg)("inlineCode",{parentName:"p"},"log4j2.xml")," that configures some of the more chatty classes to write asynchronously:"),(0,i.yg)("pre",null,(0,i.yg)("code",{parentName:"pre"},'<?xml version="1.0" encoding="UTF-8" ?>\n<Configuration status="WARN">\n <Appenders>\n <Console name="Console" target="SYSTEM_OUT">\n <PatternLayout pattern="%d{ISO8601} %p [%t] %c -%notEmpty{ [%markerSimpleName]} %m%n"/>\n </Console>\n </Appenders>\n \n<Loggers>\n \x3c!-- AsyncLogger instead of Logger --\x3e\n <AsyncLogger name="org.apache.druid.curator.inventory.CuratorInventoryManager" level="debug" additivity="false">\n <AppenderRef ref="Console"/>\n </AsyncLogger>\n <AsyncLogger name="org.apache.druid.client.BatchServerInventoryView" level="debug" additivity="false">\n <AppenderRef ref="Console"/>\n </AsyncLogger>\n \x3c!-- Make extra sure nobody adds logs in a bad way that can hurt performance --\x3e\n <AsyncLogger name="org.apache.druid.client.ServerInventoryView" level="debug" additivity="false">\n <AppenderRef ref="Console"/>\n </AsyncLogger>\n <AsyncLogger name ="org.apache.druid.java.util.http.client.pool.ChannelResourceFactory" level="info" additivity="false">\n <AppenderRef ref="Console"/>\n </AsyncLogger>\n <Root level="info">\n <AppenderRef ref="Console"/>\n </Root>\n </Loggers>\n</Configuration>\n')))}y.isMDXComponent=!0}}]);