logging

NGINX: Obfuscate password in access_log

試著忘記壹切 提交于 2020-02-06 06:39:09
问题 The bounty expires in 2 days . Answers to this question are eligible for a +50 reputation bounty. Jon Mitten is looking for a canonical answer : “This is a common requirement for cloud debugging, and the regex pattern would be very valuable.” I want to log the $request_body in the access logs. But some of the requests have some JSON fields that are sensitive like passwords. Example: [2019-03-28] 201 - POST /api/user/add HTTP/1.1 - {\x22email\x22:\x22test@test.com\x22,\x22password\x22:

Why don't Info level messages get logged when minimum level is Debug?

五迷三道 提交于 2020-02-05 05:24:04
问题 I have the following code in my C# application using Nlog. The messages with 'Debug' get logged, but 'Info' do not. I had assumed that since minLevel is set to 'Debug' in app.config, the 'Info' messages will also get logged, since Debug has higher priority over 'Info'. But they do not get logged. Where am i wrong ? Thanks. if (logger.IsDebugEnabled) logger.Debug(logMessage) else if (logger.IsInfoEnabled)log.Info(logMessage); This is the app.config setting <nlog xmlns="http://www.nlog-project

How to log NUnit Test Error or fail message?

扶醉桌前 提交于 2020-02-05 04:56:24
问题 I have a set of NUnit tests running and I would like to log the results of the test (along with some environment information) to a DB in the Teardown method after each test completes. Is there any way to get that information from the NUnit TestContext apart from writing my own NUnit add-in? I know that the fail or error messages get logged to whatever output file I specify with the console runner, but I would really like to do it programmatically. 回答1: You have access to the TestContext

How to log NUnit Test Error or fail message?

拥有回忆 提交于 2020-02-05 04:56:03
问题 I have a set of NUnit tests running and I would like to log the results of the test (along with some environment information) to a DB in the Teardown method after each test completes. Is there any way to get that information from the NUnit TestContext apart from writing my own NUnit add-in? I know that the fail or error messages get logged to whatever output file I specify with the console runner, but I would really like to do it programmatically. 回答1: You have access to the TestContext

Python logger doesn't adhere to the set level

∥☆過路亽.° 提交于 2020-02-04 04:50:28
问题 I created a logger in the Python3 interactive prompt: >>> import logging >>> logger = logging.getLogger('foo') >>> logger.setLevel(logging.INFO) >>> logger.warn('bar') bar >>> logger.info('bar') >>> I'd expect logger.info to output the bar in this case, since I've explicitly set the logging level. But it's not the case here. Why? 回答1: Actually, in your case neither should output anything since you haven't configured logging. You'll need to run logging.basicConfig() or add a handler to your

UnicodeDecodeError when logging an Exception in Python

可紊 提交于 2020-02-03 04:42:06
问题 I'm using Python 2.7.9. x32 on Win7 x64. When I'm logging an Exception containing Umlauts, I always receive UnicodeDecodeError: 'ascii' codec can't decode byte 0xfc in position 39: ordinal not in range(128) My example code is: except Exception as e: logging.error('Error loading SCMTool for repository ' '%s (ID %d): %s' % (repo.name, repo.id, e), exc_info=1) The Exception being logged is WindowsError: [Error 267] Der Verzeichnisname ist ungültig . The Problem is based on the "ung Ü ltig"

Get all logging output with mock

十年热恋 提交于 2020-02-03 04:39:46
问题 I want to get all logging output with mock. I searched, but only found ways to mock explicitly logging.info or logging.warn. I need all output, whatever logging level was set. def test_foo(): def my_log(...): logs.append(...) with mock.patch('logging.???', my_log): ... In our libraries we use this: import logging logger=logging.getLogger(__name__) def foo(): logger.info(...) 回答1: stdlib Since Python 3.4 the batteries' unittest has assertLogs. When used without logger and level arguments, it

How to remove appender from logger in log4j2 programmatically?

匆匆过客 提交于 2020-02-03 04:34:46
问题 Is there any way I can remove appender from a logger in log4j2 programmatically ? The website says "Log4j 2 API does not expose methods to add, modify or remove appenders and filters or manipulate the configuration in any way" : https://logging.apache.org/log4j/2.x/manual/configuration.html But i would really appreciate if someone can suggest an indirect way to achieve this. Thanks. 回答1: There is a method LoggerConfig#removeAppender(String name) which will remove specific appender and

how to Filter the full Log context using PowerShell

陌路散爱 提交于 2020-02-01 09:46:28
问题 I am trying to filter out the logs and its full context using Select-String in powershell. I know the parameters of context and their meanings but this limits to what I am trying to achieve. Below is the log snippet and I want to search the log with date as a search parameter to select-string filter. [AD Thread-Metric Reporter1] 16 Dec 2019 19:03:32,371 ERROR ManagedMonitorDelegate - Error sending metrics - will requeue for later transmission com.singularity.ee.agent.commonservices

how to Filter the full Log context using PowerShell

馋奶兔 提交于 2020-02-01 09:45:08
问题 I am trying to filter out the logs and its full context using Select-String in powershell. I know the parameters of context and their meanings but this limits to what I am trying to achieve. Below is the log snippet and I want to search the log with date as a search parameter to select-string filter. [AD Thread-Metric Reporter1] 16 Dec 2019 19:03:32,371 ERROR ManagedMonitorDelegate - Error sending metrics - will requeue for later transmission com.singularity.ee.agent.commonservices