Skip to main content

log.client

一款Python日志客户端,支持直接写入Elasticsearch。


功能优化:

1、支持批量写入Elasticsearch(依赖Elasticsearch包)。

2、增加日志队列慢的异常处理。


Usage:

创建配置文件config.ini:

[log]
app_name = YOUR-APPNAME
es_urls = http://es-ip:9200
es_index_name = applog-20221010

app_name: 应用名称
es_urls: Elasticsearch 地址。填写多个时,用,分隔。
es_index_name: Elasticsearch 索引名称

创建配置文件logging.ini:

[loggers]
keys=root

[handlers]
keys=consoleHandler,qHandler

[formatters]
keys=simpleFmt,detailFmt

[logger_root]
level=DEBUG
handlers=consoleHandler,qHandler

[handler_consoleHandler]
class=StreamHandler
level=DEBUG
formatter=detailFmt
args=(sys.stdout,)

[handler_qHandler]
class=qlog.logger.QlogHandler
level=INFO
formatter=simpleFmt
args=()

[formatter_detailFmt]
format="%(asctime)-15s %(levelname)s %(filename)s %(funcName)s lineNo: %(lineno)d details: %(message)s"

[formatter_simpleFmt]
format="%(message)s"

== 日志写入测试

import logging
import logging.config
from time import sleep

logging.config.fileConfig('logging.ini')
logger = logging.getLogger('root')
logger.info('这是一条中文字符测试日志')
logger.info('this is a info log.')
logger.warning('this is a warning log.')
sleep(30)

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

log.client-1.1.1.tar.gz (5.5 kB view details)

Uploaded Source

File details

Details for the file log.client-1.1.1.tar.gz.

File metadata

  • Download URL: log.client-1.1.1.tar.gz
  • Upload date:
  • Size: 5.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.8.7

File hashes

Hashes for log.client-1.1.1.tar.gz
Algorithm Hash digest
SHA256 4cec1720487dd46c96acbbb1639ab54920cdbe9f127133de10ccf271f4cc0efa
MD5 ca9d72e44b19803f52591649df2c7208
BLAKE2b-256 c0475c055a0f625b836e5aef685440fe894e032502675f20efaa8ce588513f8e

See more details on using hashes here.

Release history Release notifications | RSS feed

1.2.6

2 files

1.2.2

1 file

1.2.1

1 file

This release

1.1.1 This release

1 file

1.0.0

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page