File tree Expand file tree Collapse file tree 2 files changed +11
-20
lines changed Expand file tree Collapse file tree 2 files changed +11
-20
lines changed Original file line number Diff line number Diff line change @@ -36,7 +36,7 @@ as well as http://www.structlog.org/en/stable/[`structlog`].
3636[[logging]]
3737===== `logging`
3838
39- For Python 3.2+, we use https://docs.python.org/3/library/logging.html#logging.setLogRecordFactory[`logging.setLogRecordFactory()`]
39+ We use https://docs.python.org/3/library/logging.html#logging.setLogRecordFactory[`logging.setLogRecordFactory()`]
4040to decorate the default LogRecordFactory to automatically add new attributes to
4141each LogRecord object:
4242
@@ -51,25 +51,6 @@ You can disable this automatic behavior by using the
5151<<config-generic-disable-log-record-factory,`disable_log_record_factory`>> setting
5252in your configuration.
5353
54- For Python versions <3.2, we also provide a
55- https://docs.python.org/3/library/logging.html#filter-objects[filter] which will
56- add the same new attributes to any filtered `LogRecord`:
57-
58- [source,python]
59- ----
60- import logging
61- from elasticapm.handlers.logging import LoggingFilter
62-
63- console = logging.StreamHandler()
64- console.addFilter(LoggingFilter())
65- # add the handler to the root logger
66- logging.getLogger("").addHandler(console)
67- ----
68-
69- NOTE: Because https://docs.python.org/3/library/logging.html#filter-objects[filters
70- are not propagated to descendent loggers], you should add the filter to each of
71- your log handlers, as handlers are propagated, along with their attached filters.
72-
7354[float]
7455[[structlog]]
7556===== `structlog`
Original file line number Diff line number Diff line change @@ -194,6 +194,16 @@ class LoggingFilter(logging.Filter):
194194 automatically.
195195 """
196196
197+ def __init__ (self , name = "" ):
198+ super ().__init__ (name = name )
199+ warnings .warn (
200+ "The LoggingFilter is deprecated and will be removed in v7.0 of "
201+ "the agent. On Python 3.2+, by default we add a LogRecordFactory to "
202+ "your root logger automatically"
203+ "https://www.elastic.co/guide/en/apm/agent/python/current/logs.html" ,
204+ PendingDeprecationWarning ,
205+ )
206+
197207 def filter (self , record ):
198208 """
199209 Add elasticapm attributes to `record`.
You can’t perform that action at this time.
0 commit comments