logging

Mask Passwords with Logback?

我与影子孤独终老i 提交于 2019-12-31 17:54:30
问题 We currently generically log all XML documents coming in and going out of our system, and some of them contain passwords in the clear. We would like to be able to configure the logback logger/appender that is doing this to do some pattern matching or similar and if it detects a password is present to replace it (with asterisks most likely). Note we don't want to filter out the log entry, we want to mask a portion of it. I would appreciate advice on how this would be done with logback. Thanks.

Throw exception vs Logging

风流意气都作罢 提交于 2019-12-31 17:53:30
问题 Is the following way to code good practice? try { //my code here } catch (Exception e) { logger.error("Some error ", e); throw new MyCustomException("Some error ", e); } Moreover, should I.. use only the logger? throw only the exception? do both? I understand that with throw I can catch the exception in another part of the callstack, but maybe additional logging has some hidden benefits and is useful as well. 回答1: I use both in some cases, logging and throwing the exception. Specially, it's

Throw exception vs Logging

谁说我不能喝 提交于 2019-12-31 17:53:10
问题 Is the following way to code good practice? try { //my code here } catch (Exception e) { logger.error("Some error ", e); throw new MyCustomException("Some error ", e); } Moreover, should I.. use only the logger? throw only the exception? do both? I understand that with throw I can catch the exception in another part of the callstack, but maybe additional logging has some hidden benefits and is useful as well. 回答1: I use both in some cases, logging and throwing the exception. Specially, it's

Very simple file appender logging not working

纵饮孤独 提交于 2019-12-31 13:10:26
问题 Here's my web.config information: <configSections> <section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net"/> </configSections> <log4net> <root> <level value="ALL" /> </root> <appender name="RollingFileAppender" type="log4net.Appender.RollingFileAppender"> <file value="c:\temp\log-file.txt" /> <appendToFile value="true" /> <rollingStyle value="Size" /> <maxSizeRollBackups value="10" /> <maximumFileSize value="1MB" /> <staticLogFileName value="true" /> <layout

Redirecting stdout to file nodejs

北城余情 提交于 2019-12-31 12:35:41
问题 I've created: var access = fs.createWriteStream('/var/log/node/api.access.log', { flags: 'w' }); Then piped: process.stdout.pipe(access); Then tried: console.log("test"); And nothing has appeared in /var/log/node/api.access.log. However this way is working: process.stdout.pipe(access).write('test'); Could someone explain what am I doing wrong ? 回答1: I solved this problem the following way: var access = fs.createWriteStream('/var/log/node/api.access.log'); process.stdout.write = process.stderr

Gradle color output

蹲街弑〆低调 提交于 2019-12-31 11:27:11
问题 I've looked this up on Google, but there doesn't seem to be any documentation on the Gradle site, or even people discussing this in forums. I have Gradle installed on my Mac (10.8.2, ML) and am building a custom build.gradle script. When I call println(), I would like to make the output colored (like errors in red, info in green, etc). How do I do this in my gradle build script? Here's an example of code I have so far: def proc = "echo `DATE`".execute() proc.in.eachLine {line -> println line}

List of Log4net Conversion Patterns

早过忘川 提交于 2019-12-31 11:09:17
问题 Is there a comprehensive list of all the conversion patterns available for log4net? I can't even find them in the source code. All I have found is this; shouldn't there be more patterns? For example, how would I get the name of the hosting application? Also, how can I add my own patterns? As an example here is the comparable list but for nlog. Edit: I have found the Pattern for application name; it's [Application] . But I'm still looking for the mother-load. Can someone at least point me to

How to get the line of code that triggers a query?

这一生的挚爱 提交于 2019-12-31 10:24:14
问题 is there a way (a gem, a plugin or something else) in rails 3.2 to know which line of code triggers a database query? For example in my log I have: User Load (0.4ms) SELECT `users`.* FROM `users` WHERE `users`.`id` = 5 LIMIT 1 How can I know the line of code that triggers the query? Thx... 回答1: I've found this solution: module QueryTrace def self.enable! ::ActiveRecord::LogSubscriber.send(:include, self) end def self.append_features(klass) super klass.class_eval do unless method_defined?(:log

How to get the line of code that triggers a query?

拜拜、爱过 提交于 2019-12-31 10:23:15
问题 is there a way (a gem, a plugin or something else) in rails 3.2 to know which line of code triggers a database query? For example in my log I have: User Load (0.4ms) SELECT `users`.* FROM `users` WHERE `users`.`id` = 5 LIMIT 1 How can I know the line of code that triggers the query? Thx... 回答1: I've found this solution: module QueryTrace def self.enable! ::ActiveRecord::LogSubscriber.send(:include, self) end def self.append_features(klass) super klass.class_eval do unless method_defined?(:log

How to get the line of code that triggers a query?

对着背影说爱祢 提交于 2019-12-31 10:23:01
问题 is there a way (a gem, a plugin or something else) in rails 3.2 to know which line of code triggers a database query? For example in my log I have: User Load (0.4ms) SELECT `users`.* FROM `users` WHERE `users`.`id` = 5 LIMIT 1 How can I know the line of code that triggers the query? Thx... 回答1: I've found this solution: module QueryTrace def self.enable! ::ActiveRecord::LogSubscriber.send(:include, self) end def self.append_features(klass) super klass.class_eval do unless method_defined?(:log