Files
rancher-docs/assets/js/5f501779.a2e02c48.js
T

1 line
8.1 KiB
JavaScript

"use strict";(self.webpackChunkrancher_docs=self.webpackChunkrancher_docs||[]).push([[28866],{3905:(e,t,n)=>{n.d(t,{Zo:()=>u,kt:()=>d});var r=n(67294);function o(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function l(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function a(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?l(Object(n),!0).forEach((function(t){o(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):l(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function i(e,t){if(null==e)return{};var n,r,o=function(e,t){if(null==e)return{};var n,r,o={},l=Object.keys(e);for(r=0;r<l.length;r++)n=l[r],t.indexOf(n)>=0||(o[n]=e[n]);return o}(e,t);if(Object.getOwnPropertySymbols){var l=Object.getOwnPropertySymbols(e);for(r=0;r<l.length;r++)n=l[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}var s=r.createContext({}),c=function(e){var t=r.useContext(s),n=t;return e&&(n="function"==typeof e?e(t):a(a({},t),e)),n},u=function(e){var t=c(e.components);return r.createElement(s.Provider,{value:t},e.children)},p={inlineCode:"code",wrapper:function(e){var t=e.children;return r.createElement(r.Fragment,{},t)}},g=r.forwardRef((function(e,t){var n=e.components,o=e.mdxType,l=e.originalType,s=e.parentName,u=i(e,["components","mdxType","originalType","parentName"]),g=c(n),d=o,m=g["".concat(s,".").concat(d)]||g[d]||p[d]||l;return n?r.createElement(m,a(a({ref:t},u),{},{components:n})):r.createElement(m,a({ref:t},u))}));function d(e,t){var n=arguments,o=t&&t.mdxType;if("string"==typeof e||o){var l=n.length,a=new Array(l);a[0]=g;var i={};for(var s in t)hasOwnProperty.call(t,s)&&(i[s]=t[s]);i.originalType=e,i.mdxType="string"==typeof e?e:o,a[1]=i;for(var c=2;c<l;c++)a[c]=n[c];return r.createElement.apply(null,a)}return r.createElement.apply(null,n)}g.displayName="MDXCreateElement"},11692:(e,t,n)=>{n.r(t),n.d(t,{assets:()=>s,contentTitle:()=>a,default:()=>p,frontMatter:()=>l,metadata:()=>i,toc:()=>c});var r=n(87462),o=(n(67294),n(3905));const l={title:"Logging"},a=void 0,i={unversionedId:"troubleshooting/other-troubleshooting-tips/logging",id:"version-2.6/troubleshooting/other-troubleshooting-tips/logging",title:"Logging",description:"Log levels",source:"@site/versioned_docs/version-2.6/troubleshooting/other-troubleshooting-tips/logging.md",sourceDirName:"troubleshooting/other-troubleshooting-tips",slug:"/troubleshooting/other-troubleshooting-tips/logging",permalink:"/v2.6/troubleshooting/other-troubleshooting-tips/logging",draft:!1,editUrl:"https://github.com/rancher/rancher-docs/edit/main/versioned_docs/version-2.6/troubleshooting/other-troubleshooting-tips/logging.md",tags:[],version:"2.6",lastUpdatedAt:1673046858,formattedLastUpdatedAt:"Jan 6, 2023",frontMatter:{title:"Logging"},sidebar:"tutorialSidebar",previous:{title:"Registered Clusters",permalink:"/v2.6/troubleshooting/other-troubleshooting-tips/registered-clusters"},next:{title:"User ID Tracking in Audit Logs",permalink:"/v2.6/troubleshooting/other-troubleshooting-tips/user-id-tracking-in-audit-logs"}},s={},c=[{value:"Log levels",id:"log-levels",level:2},{value:"How to configure a log level",id:"how-to-configure-a-log-level",level:3},{value:"Kubernetes install",id:"kubernetes-install",level:4},{value:"Docker Install",id:"docker-install",level:4},{value:"Rancher machine debug logs",id:"rancher-machine-debug-logs",level:2}],u={toc:c};function p(e){let{components:t,...n}=e;return(0,o.kt)("wrapper",(0,r.Z)({},u,n,{components:t,mdxType:"MDXLayout"}),(0,o.kt)("h2",{id:"log-levels"},"Log levels"),(0,o.kt)("p",null,"The following log levels are used in Rancher:"),(0,o.kt)("table",null,(0,o.kt)("thead",{parentName:"table"},(0,o.kt)("tr",{parentName:"thead"},(0,o.kt)("th",{parentName:"tr",align:null},"Name"),(0,o.kt)("th",{parentName:"tr",align:null},"Description"))),(0,o.kt)("tbody",{parentName:"table"},(0,o.kt)("tr",{parentName:"tbody"},(0,o.kt)("td",{parentName:"tr",align:null},(0,o.kt)("inlineCode",{parentName:"td"},"info")),(0,o.kt)("td",{parentName:"tr",align:null},"Logs informational messages. This is the default log level.")),(0,o.kt)("tr",{parentName:"tbody"},(0,o.kt)("td",{parentName:"tr",align:null},(0,o.kt)("inlineCode",{parentName:"td"},"debug")),(0,o.kt)("td",{parentName:"tr",align:null},"Logs more detailed messages that can be used to debug.")),(0,o.kt)("tr",{parentName:"tbody"},(0,o.kt)("td",{parentName:"tr",align:null},(0,o.kt)("inlineCode",{parentName:"td"},"trace")),(0,o.kt)("td",{parentName:"tr",align:null},"Logs very detailed messages on internal functions. This is very verbose and can contain sensitive information.")))),(0,o.kt)("h3",{id:"how-to-configure-a-log-level"},"How to configure a log level"),(0,o.kt)("h4",{id:"kubernetes-install"},"Kubernetes install"),(0,o.kt)("ul",null,(0,o.kt)("li",{parentName:"ul"},"Configure debug log level")),(0,o.kt)("pre",null,(0,o.kt)("code",{parentName:"pre"},"$ KUBECONFIG=./kube_config_cluster.yml\n$ kubectl -n cattle-system get pods -l app=rancher --no-headers -o custom-columns=name:.metadata.name | while read rancherpod; do kubectl -n cattle-system exec $rancherpod -c rancher -- loglevel --set debug; done\nOK\nOK\nOK\n$ kubectl -n cattle-system logs -l app=rancher -c rancher\n")),(0,o.kt)("ul",null,(0,o.kt)("li",{parentName:"ul"},"Configure info log level")),(0,o.kt)("pre",null,(0,o.kt)("code",{parentName:"pre"},"$ KUBECONFIG=./kube_config_cluster.yml\n$ kubectl -n cattle-system get pods -l app=rancher --no-headers -o custom-columns=name:.metadata.name | while read rancherpod; do kubectl -n cattle-system exec $rancherpod -c rancher -- loglevel --set info; done\nOK\nOK\nOK\n")),(0,o.kt)("h4",{id:"docker-install"},"Docker Install"),(0,o.kt)("ul",null,(0,o.kt)("li",{parentName:"ul"},"Configure debug log level")),(0,o.kt)("pre",null,(0,o.kt)("code",{parentName:"pre"},"$ docker exec -ti <container_id> loglevel --set debug\nOK\n$ docker logs -f <container_id>\n")),(0,o.kt)("ul",null,(0,o.kt)("li",{parentName:"ul"},"Configure info log level")),(0,o.kt)("pre",null,(0,o.kt)("code",{parentName:"pre"},"$ docker exec -ti <container_id> loglevel --set info\nOK\n")),(0,o.kt)("h2",{id:"rancher-machine-debug-logs"},"Rancher machine debug logs"),(0,o.kt)("p",null,"If you need to troubleshoot the creation of objects in your infrastructure provider of choice, ",(0,o.kt)("inlineCode",{parentName:"p"},"rancher-machine"),"\ndebug logs might be helpful to you."),(0,o.kt)("p",null,"It's possible to enable debug logs for ",(0,o.kt)("inlineCode",{parentName:"p"},"rancher-machine")," by setting environment variables when launching Rancher."),(0,o.kt)("p",null,"The ",(0,o.kt)("inlineCode",{parentName:"p"},"CATTLE_WHITELIST_ENVVARS")," environment variable allows users to whitelist specific environment variables to be\npassed down to ",(0,o.kt)("inlineCode",{parentName:"p"},"rancher-machine")," during provisioning."),(0,o.kt)("p",null,"The ",(0,o.kt)("inlineCode",{parentName:"p"},"MACHINE_DEBUG")," variable enables debug logs in ",(0,o.kt)("inlineCode",{parentName:"p"},"rancher-machine"),"."),(0,o.kt)("p",null,"Thus, by setting ",(0,o.kt)("inlineCode",{parentName:"p"},"MACHINE_DEBUG=true")," and adding ",(0,o.kt)("inlineCode",{parentName:"p"},"MACHINE_DEBUG")," to the default list of variables in\n",(0,o.kt)("inlineCode",{parentName:"p"},"CATTLE_WHITELIST_ENVVARS")," (e.g. ",(0,o.kt)("inlineCode",{parentName:"p"},"CATTLE_WHITELIST_ENVVARS=HTTP_PROXY,HTTPS_PROXY,NO_PROXY,MACHINE_DEBUG"),") it is\npossible to enable debug logs in ",(0,o.kt)("inlineCode",{parentName:"p"},"rancher-machine")," when provisioning RKE1, RKE2 and k3s clusters."),(0,o.kt)("admonition",{type:"caution"},(0,o.kt)("p",{parentName:"admonition"},"Just like the ",(0,o.kt)("inlineCode",{parentName:"p"},"trace")," log level above, ",(0,o.kt)("inlineCode",{parentName:"p"},"rancher-machine")," debug logs can contain sensitive information.")))}p.isMDXComponent=!0}}]);