问题标签 [appender]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
1 回答
3017 浏览

java - 在 log4j JDBCAppender 中保存额外的值

我想在我的日志表中存储额外的值,例如将用户 ID 存储在单独的列中。有人知道我该怎么做吗?

这是我的配置:

谢谢

0 投票
2 回答
263 浏览

java - 如何使用 Log4J 将日志记录输出专门定向到不同的记录器

我想使用 Log4J 将非常特定性质的输出发送到与为其他所有内容指定的日志不同的日志。现在,我有一个 log4j.properties,看起来有点像:

我只想要 appender 中 LoggerSPECIAL_LOGGERspecials输出——很简单——但我不想要appenderSPECIAL_LOGGER中的catchall输出。我认为这意味着我不能用日志级别做我需要的事情。

有任何想法吗?

0 投票
2 回答
2240 浏览

rest - 哪个 Logback Appender 用于通过 REST 接收器端点向 splunk 发送新事件?

如果我正在使用 logback 框架,如果我想使用 Splunk 的 REST 接收器端点创建新事件,我应该使用哪个 Logback appender。我想为此制作一个自定义的基本附加程序?它是套接字附加器吗?

0 投票
1 回答
765 浏览

log4j - 带有文件 url 的 log4j appender

我有一个问题,log4j 没有记录到我的文件之一,我不知道为什么。我有一些运行脚本的代码,这些脚本可以添加使用 log4j 记录到文件中的日志记录,我正在尝试创建一个仅记录特定脚本的附加程序。

上面的附加程序有效,我在我的日志文件中得到了这个

com.my.class.file:/myfile当脚本记录某些内容时,它会使用我的 log4j.properties 文件中的上述配置将其记录到表单的记录器中 。

如果我将以上内容更改为:

没有任何内容记录到文件中。我会认为这应该工作?我检索文件

0 投票
2 回答
6083 浏览

java - 制作一个记录器以跳过 logback 中的根部分

我定义了几个记录器和一个带有多个附加程序的根部分,例如:

我想要完成的是让名为 Z 的记录器转到 ALERTS-SYSLOG 附加程序,而不是根部分中定义的所有附加程序。只有在 XML 文件上配置才有可能吗?

0 投票
1 回答
546 浏览

java - Logback appender 和 Postfix

我正在尝试创建一个附加程序来过滤低于错误级别的任何日志并使用这些日志发送电子邮件。这就是我的 logback.xml 文件的样子(只是 appender 部分):

smtpHostlocalhost在哪里usernamepassword属于我在运行应用程序的服务器上创建的用户。它似乎不起作用 - 没有发送电子邮件。

但是,当我为另一台服务器(即 )设置参数时smtpHost = smtp.gmail.com,我会按预期收到电子邮件。

我想这意味着我在服务器上配置后缀的方式有问题。我很乐意在此处发布main.cf文件中的任何信息(我只是不想全部发布)。

0 投票
3 回答
47272 浏览

log4j - 如何在 log4j 中使用 AsyncAppender?

如何在 log4j 中使用 AsyncAppender 将日志消息写入 Web 服务?我应该创建自己的 Appender 来扩展 AsyncAppender 还是只是将自定义附加程序附加到 AsyncAppender?如果第二个选择是正确的,我应该把 AsyncAppender 对象放在哪里?有什么例子吗?

0 投票
2 回答
261 浏览

java - log4J 的所有附加程序

我尝试运行带有很多外部 jar 的中型程序,但我总是收到警告“log4j:WARN No appenders could be found for logger XYZ”。当然,我必须将特定的 Appender 添加到我的 log4j.properties 但如果我添加这个,下次运行会错过另一个。

那么,除了启动、添加appender、启动、添加appender ..等等,还有什么方法可以在外部jar中找到所有需要的appender,直到没有更多警告?

0 投票
1 回答
1623 浏览

layout - 如何在 SocketAppender 中使用模式布局

我读过 org.apache.log4j.net.SocketAppender 不使用布局。但是,我真的需要格式化我的日志并且我需要使用 ConversionPattern。有人知道这个的替代品吗?我必须使用某种 SocketAppender。

谢谢

0 投票
2 回答
13324 浏览

c# - log4net BufferingForwardingAppender performance issue

EDIT 2 : I have solved the problem (see answer below) Please note that the problem potentially affects all appenders decorated with BufferingForwardingAppender as well as all appenders inheriting from BufferingAppenderSkeleton (respectively : AdoNetAppender, RemotingAppender, SmtpAppender and SmtpPickupDirAppender) *

I was doing some very basic benchs of log4net and I tried to decorate a RollingFileAppender with a BufferingForwardingAppender.

I experience terrible performance going through the BufferingForwardingAppender instead of directly through the RollingFileAppender and I really don't get the reason.

Here is my configuration:

And here is the benchmark (very simple code):

Going directly through RollingFileAppender the output is:

Done in 511 ms

Whereas going through the BufferingForwardingAppender decorating the RollingFileAppender :

Done in 14261 ms

That's approx 30 times slower.

I thought I would gain some speed by buffering a certain amount of log before writing them to the file, however for some reason it gets things much worse.

Seems to me like the configuration is OK, so this is really weird.

Anyone got a clue?

Thanks!

EDIT 1 :

The behavior is strictly the same by wrapping/decorating a FileAppender or even ConsoleAppender (still there is an example of basic BufferingForwardingAppender wrapping/decorating ConsoleAppender in log4net official config samples .. and nothing specific mentioned dealing with performance).

After some investigation/profiling, I can see that the majority of the time is spoiled inside the BufferingForwardingAppender more specifically in a call to WindowsIdentity.GetCurrent() ... being called EACH time we make a call to Log.Debug() .. in the previous sample (100K times in the sample source above).

Calls to this method are known to be very costly and should be avoided or minimized, I really don't get why it gets called for each log event. Am I really completely misconfiguring something / not seeing something evident, or is that a bug somehow somewhere, this is what I am trying to figure out now...

The partial call stack is :

  • AppenderSkeleton.DoAppend
  • BufferingAppenderSkeleton.Append
  • LoggingEvent.FixVolatileData
  • LoggingEvent.get_UserName()

A call to get_LocationInformation() is also done in FixVolatileData, incurring an high perf cost as well (capture the stack trace each time).

I am now trying to understand why this extremely costly FixVolatileData call (at least for the fix asked) happens for each log event in this context whereas going directly through the wrapped appender (directly through ConsoleAppender/FileAppender ..) does not perform this kind of operation.

Upcoming update to follow, unless someone got an answer to all of this ;)

Thanks!