PageSourceSearch

https://hydra.cc/assets/js/897ccb8c.19d13f34.js

js hydra.cc collected 2026-10-03 20:39:25 UTC 5,769 bytes, 1 lines download raw bytes

1"use strict";(self.webpackChunkwebsite=self.webpackChunkwebsite||[]).push([[2348],{18449(e,n,o){o.r(n),o.d(n,{assets:()=>a,contentTitle:()=>g,default:()=>u,frontMatter:()=>l,metadata:()=>i,toc:()=>c});const i=JSON.parse('{"id":"tutorials/basic/running_your_app/logging","title":"Logging","description":"People often do not use Python logging due to the setup cost.","source":"@site/versioned_docs/version-1.1/tutorials/basic/running_your_app/4_logging.md","sourceDirName":"tutorials/basic/running_your_app","slug":"/tutorials/basic/running_your_app/logging","permalink":"/docs/1.1/tutorials/basic/running_your_app/logging","draft":false,"unlisted":false,"editUrl":"https://github.com/hydra-ecosystem/hydra/edit/main/website/versioned_docs/version-1.1/tutorials/basic/running_your_app/4_logging.md","tags":[],"version":"1.1","sidebarPosition":4,"frontMatter":{"id":"logging","title":"Logging","sidebar_label":"Logging"},"sidebar":"docs","previous":{"title":"Output/Working directory","permalink":"/docs/1.1/tutorials/basic/running_your_app/working_directory"},"next":{"title":"Debugging","permalink":"/docs/1.1/tutorials/basic/running_your_app/debugging"}}');var t=o(94686),r=o(23629),s=o(75766);const l={id:"logging",title:"Logging",sidebar_label:"Logging"},g=void 0,a={},c=[];function d(e){const n={a:"a",code:"code",li:"li",p:"p",pre:"pre",strong:"strong",ul:"ul",...(0,r.R)(),...e.components};return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(s.C,{to:"examples/tutorials/basic/running_your_hydra_app/4_logging/my_app.py"}),"\n",(0,t.jsx)(n.p,{children:"People often do not use Python logging due to the setup cost.\nHydra solves this by configuring the Python logging for you."}),"\n",(0,t.jsx)(n.p,{children:"By default, Hydra logs at the INFO level to both the console and a log file in the automatic working directory."}),"\n",(0,t.jsx)(n.p,{children:"An example of logging with Hydra:"}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-python",children:'import logging\nfrom omegaconf import DictConfig\nimport hydra\n\n# A logger for this file\nlog = logging.getLogger(__name__)\n\[email protected]()\ndef my_app(_cfg: DictConfig) -> None:\n    log.info("Info level message")\n    log.debug("Debug level message")\n\nif __name__ == "__main__":\n    my_app()\n\n$ python my_app.py\n[2019-06-27 00:52:46,653][__main__][INFO] - Info level message\n\n'})}),"\n",(0,t.jsxs)(n.p,{children:["You can enable DEBUG level logging from the command line  by overriding ",(0,t.jsx)(n.code,{children:"hydra.verbose"}),"."]}),"\n",(0,t.jsxs)(n.p,{children:[(0,t.jsx)(n.code,{children:"hydra.verbose"})," can be a Boolean, a String or a List:"]}),"\n",(0,t.jsx)(n.p,{children:"Examples:"}),"\n",(0,t.jsxs)(n.ul,{children:["\n",(0,t.jsxs)(n.li,{children:[(0,t.jsx)(n.code,{children:"hydra.verbose=true"})," : Sets the log level of ",(0,t.jsx)(n.strong,{children:"all"})," loggers to ",(0,t.jsx)(n.code,{children:"DEBUG"})]}),"\n",(0,t.jsxs)(n.li,{children:[(0,t.jsx)(n.code,{children:"hydra.verbose=NAME"})," : Sets the log level of the logger ",(0,t.jsx)(n.code,{children:"NAME"})," to ",(0,t.jsx)(n.code,{children:"DEBUG"}),".\nEquivalent to ",(0,t.jsx)(n.code,{children:"import logging; logging.getLogger(NAME).setLevel(logging.DEBUG)"}),"."]}),"\n",(0,t.jsxs)(n.li,{children:[(0,t.jsx)(n.code,{children:"hydra.verbose=[NAME1,NAME2]"}),": Sets the log level of the loggers ",(0,t.jsx)(n.code,{children:"NAME1"})," and ",(0,t.jsx)(n.code,{children:"NAME2"})," to ",(0,t.jsx)(n.code,{children:"DEBUG"})]}),"\n"]}),"\n",(0,t.jsx)(n.p,{children:"Example output:"}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-text",children:"$ python my_app.py hydra.verbose=[__main__,hydra]\n[2019-09-29 13:06:00,880] - Installed Hydra Plugins\n[2019-09-29 13:06:00,880] - ***********************\n...\n[2019-09-29 13:06:00,896][__main__][INFO] - Info level message\n[2019-09-29 13:06:00,896][__main__][DEBUG] - Debug level message\n"})}),"\n",(0,t.jsxs)(n.p,{children:["You can disable the logging output by setting ",(0,t.jsx)(n.code,{children:"hydra/job_logging"})," to ",(0,t.jsx)(n.code,{children:"disabled"})]}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-commandline",children:"$ python my_app.py hydra/job_logging=disabled\n<NO OUTPUT>\n"})}),"\n",(0,t.jsxs)(n.p,{children:["You can also set ",(0,t.jsx)(n.code,{children:"hydra/job_logging=none"})," and ",(0,t.jsx)(n.code,{children:"hydra/hydra_logging=none"})," if you do not want Hydra to configure the logging."]}),"\n",(0,t.jsxs)(n.p,{children:["Logging can be ",(0,t.jsx)(n.a,{href:"/docs/1.1/configure_hydra/logging",children:"customized"}),"."]})]})}function u(e={}){const{wrapper:n}={...(0,r.R)(),...e.components};return n?(0,t.jsx)(n,{...e,children:(0,t.jsx)(d,{...e})}):d(e)}},75766(e,n,o){o.d(n,{A:()=>g,C:()=>a});o(92990);var i=o(88512),t=o(81928),r=o(91471),s=o(94686);function l(e){var n;const o=(0,r.ir)();return(0,t.A)().siteConfig.customFields.githubLinkVersionToBaseUrl[null!=(n=null==o?void 0:o.name)?n:"current"]+e}function g(e){return(0,s.jsx)(i.A,Object.assign({},e,{to:l(e.to),target:"_blank"}))}function a(e){var n;const o=null!=(n=e.text)?n:"Example (Click Here)";return(0,s.jsxs)(g,Object.assign({},e,{children:[(0,s.jsx)("span",{children:"\xa0"}),(0,s.jsx)("img",{src:"https://img.shields.io/badge/-"+o+"-informational",alt:"Example (Click Here)"})]}))}},23629(e,n,o){o.d(n,{R:()=>s,x:()=>l});var i=o(92990);const t={},r=i.createContext(t);function s(e){const n=i.useContext(r);return i.useMemo(function(){return"function"==typeof e?e(n):{...n,...e}},[n,e])}function l(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(t):e.components||t:s(e.components),i.createElement(r.Provider,{value:n},e.children)}}}]);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.