logging

get line number and filename for a log output

倖福魔咒の 提交于 2020-01-14 08:24:06
问题 Is it possible to get the line number and file for each log output ? For example: var winston = require('winston'); winston.log('info', 'some message!'); // this is at line 4 of myfile.js should specify in log file that 'some message' came from myFile.js line 4. 回答1: You can pass the file name as label and you can get the file name from callingModule. Create logger.js file and code like var winston = require('winston'); var getLabel = function (callingModule) { var parts = callingModule

get line number and filename for a log output

本秂侑毒 提交于 2020-01-14 08:23:13
问题 Is it possible to get the line number and file for each log output ? For example: var winston = require('winston'); winston.log('info', 'some message!'); // this is at line 4 of myfile.js should specify in log file that 'some message' came from myFile.js line 4. 回答1: You can pass the file name as label and you can get the file name from callingModule. Create logger.js file and code like var winston = require('winston'); var getLabel = function (callingModule) { var parts = callingModule

How to make std::wofstream write UTF-8?

▼魔方 西西 提交于 2020-01-14 04:25:44
问题 I am redirecting std::wclog to a file for logging in my program: std::wclog.rdbuf((new std::wofstream("C:\\path\\to\\file.log", std::ios::app))->rdbuf()); Logging happens by writing to std::wclog : std::wclog << "Schöne Grüße!" << std::endl; Surprisingly I found that the file is being written in ANSI. (This would be totally acceptable for ofstream and clog , but I had expected wofstream and wclog to produce some kind of unicode output.) I want to be able to log in CYK langugages as well (e.g.

python multiprocessing logging: QueueHandler with RotatingFileHandler “file being used by another process” error

余生长醉 提交于 2020-01-14 04:22:31
问题 I'm converting a program to multiprocessing and need to be able to log to a single rotating log from the main process as well as subprocesses. I'm trying to use the 2nd example in the python cookbook Logging to a single file from multiple processes, which starts a logger_thread running as part of the main process, picking up log messages off a queue that the subprocesses add to. The example works well as is, and also works if I switch to a RotatingFileHandler. However if I change it to start

python multiprocessing logging: QueueHandler with RotatingFileHandler “file being used by another process” error

五迷三道 提交于 2020-01-14 04:22:08
问题 I'm converting a program to multiprocessing and need to be able to log to a single rotating log from the main process as well as subprocesses. I'm trying to use the 2nd example in the python cookbook Logging to a single file from multiple processes, which starts a logger_thread running as part of the main process, picking up log messages off a queue that the subprocesses add to. The example works well as is, and also works if I switch to a RotatingFileHandler. However if I change it to start

Serilog not working with Elasticsearch

﹥>﹥吖頭↗ 提交于 2020-01-14 03:47:26
问题 I have installed Elasticsearch locally on my Windows 7 machine. It is working properly and I can query it using postman. Using Postman, I have also created an index called cmstest. This has a table called zdsf. If I get the mapping (http://localhost:9200/cmstest/_mapping) for this index I get the following: I can post entries to this table as well using Postman. Now, I am trying to use Serilog from my .NET 4.5 application to log to this localhost instance of Elasticsearch.But nothing seems to

How to regex Apache log date and time into Hive

牧云@^-^@ 提交于 2020-01-14 03:36:07
问题 I want to put my logfiles into a hive (Amazon Athena) My regex is OK, says the tester: https://regex101.com/r/hF4fP8/11 My create table is this: CREATE EXTERNAL TABLE IF NOT EXISTS webservicelogs.Test15 ( `day` int, `month` string, `year` int, `hour` int, `minute` int, `second` int, `offset` string ) ROW FORMAT SERDE 'org.apache.hadoop.hive.serde2.RegexSerDe' WITH SERDEPROPERTIES ('input.regex' = '\[(\d{2})\/([a-zA-Z]{3})\/(\d{4}):(\d{2}):(\d{2}):(\d{2})\s(\+\d{4})]' ) LOCATION 's3://getag

AOP Logging with StructureMap

被刻印的时光 ゝ 提交于 2020-01-14 03:26:06
问题 I am trying to implement simple logging with AOP approach with StructureMap. Basically, I want to do what is asked in the question Castle, AOP and Logging in .NET with StructureMap. CastleWindsor has the helpful IInterceptor that you can implement and then control when the a method is called with the IInvocation.Proceed() . Allowing you to perform logging before and after the call to the method is made. How can achieve this with StructureMap? I have tired using a custom Interceptor but the

Application logging

非 Y 不嫁゛ 提交于 2020-01-14 02:44:10
问题 I have a WinForms application and I need to log all exceptions (to a file, to a webservice, whatever), either handled and unhandled. How can I do this? 回答1: The most commonly used logging framework in the .NET world is log4net. There are two steps that are required to integrate log4net in your application: Configure log4.net. For example, check out FileAppender on log4net Config Examples page. Prepare your classes to use log4net: Each class should contain a field used for logging: private

HAProxy 1.4 - Don't log 2xx, only log 5xx

柔情痞子 提交于 2020-01-14 02:22:06
问题 Good evening, I'm using HAProxy (ver 1.4.24) as a load balancer for ~3000 requests per second. I am trying to log only 5xx responses, but I am unable to achive that. I am using the following configuration: http://pastebin.com/TsTk9GQE This configuration also logs 2xx requests, as long as 5xx and 4xx. I need only 5xx and 4xx, or just 5xx. Thanks, 回答1: There is an option called "dontlog-normal" in HAProxy to log only errors (whatever type of errors). Just enable it in your defaults section.