Sample program that outputs syslog with Python logging

#!/usr/bin/python  
# -*- coding: utf-8 -*-
import logging
import logging.handlers

logging.basicConfig(filename='/tmp/logger.log', level=logging.DEBUG)
log = logging.getLogger("test_logge_name")

syslog_handler = logging.handlers.SysLogHandler(address="/dev/log", facility=logging.handlers.SysLogHandler.LOG_LOCAL1)
#syslog_handler.setLevel(logging.WARNING)

log.addHandler(syslog_handler)
log.debug('Test Debug message')
log.info('Test Info message')
log.warning('Test Warning message')
log.error('Test Error message')
log.critical('Test Critical message')

Recommended Posts

Sample program that outputs syslog with Python logging
[Python] A program that creates stairs with #
One-liner that outputs 10000 digits of pi with Python
Sample data created with python
map function-Basic Python grammar learned with an interesting sample program
Debug python multiprocess program with VSCode
[Python algorithm] A program that outputs Sudoku answers from a depth-first search
Try logging in to qiita with Python
2D FEM stress analysis program with Python
HTML document your Python program with Sphinx
Visualize point P that works with Python
Sample program to display video with PyQt
A program that plays rock-paper-scissors using Python
Python Logging
[Python] A program that rounds the score
Sample to convert image to Wavelet with Python
One liner that outputs multiplication tables in Python
Create test data like that with Python (Part 1)
A program that removes duplicate statements in Python
Sample to send slack notification with python lambda
Formulas that appear in Doing Math with Python
Generate n correlated pseudo-random numbers (with Python sample)
[Python] Shopping program
FizzBuzz with Python3
Scraping with Python
Statistics with python
Scraping with Python
Python with Go
Twilio with Python
Python closure sample
Integrate with Python
Play with 2016-Python
Python> Implementation that synthesizes 3 files with variable columns and outputs 3 items on each line
AES256 with python
Tested with Python
python starts with ()
with syntax (Python)
Bingo with python
Zundokokiyoshi with python
Excel with Python
Microcomputer with Python
Cast with python
[Python] A program that counts the number of valleys
Specific sample code for working with SQLite3 in Python
String manipulation with python & pandas that I often use
List of sample program distribution sites for python books
Note that writing like this with ruby is writing like this with python
Try embedding Python in a C ++ program with pybind11
Use Cursur that closes automatically with sqlite3 in Python
Python knowledge notes that can be used with AtCoder
One liner that outputs 1000000 digits of pi in Python
Output log in JSON format with Python standard logging
From buying a computer to running a program with python
Python program that looks for the same file name
A server that echoes data POSTed with flask / python
A program to write Lattice Hinge with Rhinoceros with Python
A memo that I touched the Datastore with python
[Python] Create a Tkinter program distribution file with cx_Freeze
Using a Python program with fluentd's exec_filter Output Plugin
[Python] A program that compares the positions of kangaroos.
Articles that enable system development with Django (Python) _Introduction