Skip to content

Instantly share code, notes, and snippets.

@Rustam-Z
Created February 10, 2022 07:41
Show Gist options
  • Save Rustam-Z/91d2e7e74098c82c6d1f35abff353d62 to your computer and use it in GitHub Desktop.
Save Rustam-Z/91d2e7e74098c82c6d1f35abff353d62 to your computer and use it in GitHub Desktop.
Python logging module
import logging
logging.basicConfig(level=logging.INFO, filename='app.log', filemode='w', format='%(name)s - %(levelname)s - %(message)s')
logging.info('This will get logged')
"""
import logging.config
logging.basicConfig(
level=logging.INFO,
format="%(asctime)s [%(levelname)s] %(message)s",
handlers=[
logging.FileHandler("log_file.log"),
logging.StreamHandler()
]
)
logger = logging.getLogger(__name__)
logger.info('message')
logger.error('message')
"""
@RustamZokirovTR
Copy link

🤘

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment