Git Product home page Git Product logo

aliyun-log-logback-appender's People

Contributors

brucewu-fly avatar chaolee50 avatar crimson-gao avatar lionbule avatar sandbeach avatar zzboy avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

aliyun-log-logback-appender's Issues

日志自定义字段、以及上传自定义对象信息

在LoghubAppender中

 Optional.ofNullable(event.getArgumentArray()).map(m->{
            for(Object o : m){
                if(o instanceof LogFieldExpand){
                    ((LogFieldExpand)o).addLogItem(item);
                }
            }
            return m;
        });
 Optional.ofNullable(bufferFields)
                .ifPresent(list->{
                    Optional.ofNullable(event.getMDCPropertyMap()).map(m->{
                        m.entrySet().stream().filter(v->list.contains(v.getKey())).forEach(map->{
                            item.PushBack(map.getKey(),map.getValue());
                        });
                        return m;
                    });
                });

bufferFields 是xml中自定义字段如fields中传入在append start时转换而成的list类型
LogFieldExpand 是个接口,在log.info(null,object)传入的对象,需要实现这个接口就可以把指定的属性push进去

protobuf-java 最新的版本 3.11.4 ,文档上写的是 2.5.0 , 可以把这两个版本匹配清楚

protobuf-java 最新的版本 3.11.4 ,文档上写的是 2.5.0 ,我试了一下,是可以用的

com.google.protobuf protobuf-java 3.11.4

======== 以下是文档中的内容

com.google.protobuf
protobuf-java
2.5.0


com.aliyun.openservices
aliyun-log-logback-appender
0.1.15

但改成 aliyun-log-logback-appender 0.1.16 ,运行报错
希望指定一个准确的配置

23:37:50,791 |-INFO in ch.qos.logback.classic.LoggerContext[default] - Found resource [logback.xml] at [jar:file:/Users/rachelzhao/dev/local_repo/com/aliyun/openservices/aliyun-log-logback-appender/0.1.16/aliyun-log-logback-appender-0.1.16.jar!/logback.xml]
23:37:50,797 |-INFO in ch.qos.logback.core.joran.spi.ConfigurationWatchList@271053e1 - URL [jar:file:/Users/rachelzhao/dev/local_repo/com/aliyun/openservices/aliyun-log-logback-appender/0.1.16/aliyun-log-logback-appender-0.1.16.jar!/logback.xml] is not of type file
23:37:50,893 |-INFO in ch.qos.logback.classic.joran.action.ConfigurationAction - debug attribute not set
23:37:50,895 |-INFO in ch.qos.logback.core.joran.action.ShutdownHookAction - About to instantiate shutdown hook of type [ch.qos.logback.core.hook.DelayingShutdownHook]
23:37:50,902 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - About to instantiate appender of type [com.aliyun.openservices.log.logback.LoghubAppender]
23:37:50,914 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - Naming appender as [loghubAppender1]
23:37:50,944 |-ERROR in com.aliyun.openservices.log.logback.LoghubAppender[loghubAppender1] - Failed to start LoghubAppender. java.lang.NullPointerException: endpoint cannot be null
at java.lang.NullPointerException: endpoint cannot be null
at at com.aliyun.openservices.aliyun.log.producer.ProjectConfig.(ProjectConfig.java:48)
at at com.aliyun.openservices.log.logback.LoghubAppender.buildProjectConfig(LoghubAppender.java:93)
at at com.aliyun.openservices.log.logback.LoghubAppender.createProducer(LoghubAppender.java:86)
at at com.aliyun.openservices.log.logback.LoghubAppender.doStart(LoghubAppender.java:81)
at at com.aliyun.openservices.log.logback.LoghubAppender.start(LoghubAppender.java:69)
at at ch.qos.logback.core.joran.action.AppenderAction.end(AppenderAction.java:90)
at at ch.qos.logback.core.joran.spi.Interpreter.callEndAction(Interpreter.java:309)
at at ch.qos.logback.core.joran.spi.Interpreter.endElement(Interpreter.java:193)
at at ch.qos.logback.core.joran.spi.Interpreter.endElement(Interpreter.java:179)
at at ch.qos.logback.core.joran.spi.EventPlayer.play(EventPlayer.java:62)
at at ch.qos.logback.core.joran.GenericConfigurator.doConfigure(GenericConfigurator.java:165)
at at ch.qos.logback.core.joran.GenericConfigurator.doConfigure(GenericConfigurator.java:152)
at at ch.qos.logback.core.joran.GenericConfigurator.doConfigure(GenericConfigurator.java:110)
at at ch.qos.logback.core.joran.GenericConfigurator.doConfigure(GenericConfigurator.java:53)
at at ch.qos.logback.classic.util.ContextInitializer.configureByResource(ContextInitializer.java:75)
at at ch.qos.logback.classic.util.ContextInitializer.autoConfig(ContextInitializer.java:150)
at at org.slf4j.impl.StaticLoggerBinder.init(StaticLoggerBinder.java:84)
at at org.slf4j.impl.StaticLoggerBinder.(StaticLoggerBinder.java:55)
at at org.slf4j.LoggerFactory.bind(LoggerFactory.java:150)
at at org.slf4j.LoggerFactory.performInitialization(LoggerFactory.java:124)
at at org.slf4j.LoggerFactory.getILoggerFactory(LoggerFactory.java:417)
at at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:362)
at at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:388)

aliyun-log-logback-appender结合aliyun pandora开发有问题

项目启动时,logback.xml文件会被载入两次
第一次正常启动,第二次pandora启动再次读取这个日志配置文件,但第二次就报错了。

17:39:02,380 |-INFO in ch.qos.logback.classic.LoggerContext[default] - Could NOT find resource [logback-test.xml]
17:39:02,380 |-INFO in ch.qos.logback.classic.LoggerContext[default] - Could NOT find resource [logback.groovy]
17:39:02,380 |-INFO in ch.qos.logback.classic.LoggerContext[default] - Found resource [logback.xml] at [file:/Users/xuwenjun/IdeaProjects/bc-dispatcher/target/classes/logback.xml]
17:39:02,453 |-INFO in ch.qos.logback.classic.joran.action.ConfigurationAction - debug attribute not set
17:39:02,454 |-INFO in ch.qos.logback.core.joran.action.ShutdownHookAction - About to instantiate shutdown hook of type [ch.qos.logback.core.hook.DelayingShutdownHook]
17:39:02,458 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - About to instantiate appender of type [ch.qos.logback.core.ConsoleAppender]
17:39:02,467 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - Naming appender as [console]
17:39:02,472 |-INFO in ch.qos.logback.core.joran.action.NestedComplexPropertyIA - Assuming default type [ch.qos.logback.classic.encoder.PatternLayoutEncoder] for [encoder] property
17:39:02,508 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - About to instantiate appender of type [com.aliyun.openservices.log.logback.LoghubAppender]
17:39:02,509 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - Naming appender as [test1]
17:39:02,510 |-INFO in ch.qos.logback.core.joran.action.NestedComplexPropertyIA - Assuming default type [ch.qos.logback.classic.encoder.PatternLayoutEncoder] for [encoder] property
17:39:02,624 |-INFO in ch.qos.logback.core.joran.action.StatusListenerAction - Added status listener of type [ch.qos.logback.core.status.OnConsoleStatusListener]
17:39:02,626 |-INFO in ch.qos.logback.classic.joran.action.RootLoggerAction - Setting level of ROOT logger to INFO
17:39:02,626 |-INFO in ch.qos.logback.core.joran.action.AppenderRefAction - Attaching appender named [console] to Logger[ROOT]
17:39:02,627 |-INFO in ch.qos.logback.core.joran.action.AppenderRefAction - Attaching appender named [test1] to Logger[ROOT]
17:39:02,627 |-INFO in ch.qos.logback.classic.joran.action.ConfigurationAction - End of configuration.
17:39:02,627 |-INFO in ch.qos.logback.classic.joran.JoranConfigurator@1d16f93d - Registering current configuration as safe fallback point
2019-02-20 17:39:02,630 [main] INFO c.a.o.log.producer.inner.IOThread - The IOThread is going to work.
SLF4J: A number (3) of logging calls during the initialization phase have been intercepted and are
SLF4J: now being replayed. These are subject to the filtering rules of the underlying logging system.
SLF4J: See also http://www.slf4j.org/codes.html#replay
fail to download http://mvnrepo.alibaba-inc.com/mvn/repository/com/alibaba/citrus/tool/antx-autoconfig/1.2-jdk9/antx-autoconfig-1.2-jdk9.jar to /Users/xuwenjun/.autoconf/autoconf-1.2-jdk9.jar
/Users/xuwenjun/.autoconf/autoconf-1.2-jdk9.jar doesn't exist.


| _ \ __ _ _ __ | | ___ _ __ __ _ | __ ) ___ ___ | |
| |_) / _ | '_ \ / _ |/ _ | '
/ ` | | _ \ / _ \ / _ | __|
| __/ (
| | | | | (| | () | | | (| | | |) | () | () | |_
|| _,|| ||_,_|_
/|| _,| |___/ _/ __/ __|
:: Pandora Boot :: 2.1.7.8

Set log4j.defaultInitOverride to true.
JM.Log:INFO Init JM logger with Log4jLoggerFactory
JM.Log:INFO Log root path: /Users/xuwenjun/logs/
JM.Log:INFO Set pandora log path: /Users/xuwenjun/logs/pandora
JM.Log:INFO Init JM logger with Log4jLoggerFactory
JM.Log:INFO Log root path: /Users/xuwenjun/logs/
JM.Log:INFO Set pandora log path: /Users/xuwenjun/logs/pandora
INFO: spas-client-initializer init
JM.Log:INFO Init JM logger with Slf4jLoggerFactory
JM.Log:INFO Log root path: /Users/xuwenjun/logs/
JM.Log:INFO Set spas log path: /Users/xuwenjun/logs/spas
JM.Log:INFO Init JM logger with Slf4jLoggerFactory success, vipserver-client's ModuleClassLoader
JM.Log:INFO Log root path: /Users/xuwenjun/logs/
JM.Log:INFO Set vipsrv-logs log path: /Users/xuwenjun/logs/vipsrv-logs
17:39:09,935 |-INFO in ch.qos.logback.classic.LoggerContext[default] - Could NOT find resource [logback-test.xml]
17:39:09,935 |-INFO in ch.qos.logback.classic.LoggerContext[default] - Could NOT find resource [logback.groovy]
17:39:09,936 |-INFO in ch.qos.logback.classic.LoggerContext[default] - Found resource [logback.xml] at [file:/Users/xuwenjun/IdeaProjects/bc-dispatcher/target/classes/logback.xml]
17:39:10,011 |-INFO in ch.qos.logback.classic.joran.action.ConfigurationAction - debug attribute not set
17:39:10,014 |-INFO in ch.qos.logback.core.joran.action.ShutdownHookAction - About to instantiate shutdown hook of type [ch.qos.logback.core.hook.DelayingShutdownHook]
17:39:10,017 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - About to instantiate appender of type [ch.qos.logback.core.ConsoleAppender]
17:39:10,031 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - Naming appender as [console]
17:39:10,040 |-INFO in ch.qos.logback.core.joran.action.NestedComplexPropertyIA - Assuming default type [ch.qos.logback.classic.encoder.PatternLayoutEncoder] for [encoder] property
17:39:10,100 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - About to instantiate appender of type [com.aliyun.openservices.log.logback.LoghubAppender]
17:39:10,104 |-ERROR in ch.qos.logback.core.joran.action.AppenderAction - Could not create an Appender of type [com.aliyun.openservices.log.logback.LoghubAppender]. ch.qos.logback.core.util.IncompatibleClassException
at ch.qos.logback.core.util.IncompatibleClassException
at at ch.qos.logback.core.util.OptionHelper.instantiateByClassNameAndParameter(OptionHelper.java:58)
at at ch.qos.logback.core.util.OptionHelper.instantiateByClassName(OptionHelper.java:45)
at at ch.qos.logback.core.util.OptionHelper.instantiateByClassName(OptionHelper.java:34)
at at ch.qos.logback.core.joran.action.AppenderAction.begin(AppenderAction.java:52)
at at ch.qos.logback.core.joran.spi.Interpreter.callBeginAction(Interpreter.java:269)
at at ch.qos.logback.core.joran.spi.Interpreter.startElement(Interpreter.java:145)
at at ch.qos.logback.core.joran.spi.Interpreter.startElement(Interpreter.java:128)
at at ch.qos.logback.core.joran.spi.EventPlayer.play(EventPlayer.java:50)

会有死循环打log的情况发生吗

我打个普通的日志,logback appender会发到producer,producer又打印自己的log,这个log通过appender再调用了log producer......循环

SpringBoot print "Process finished with exit code 0" after declare Aliyun Appender in xml

Everything works fine before adding "aliyun" appender.
I'm using Spring Boot with version '2.2.2.RELEASE'.
When adds this appender, the output shows 'Process finished with exit code 0' directly without any error output.
I have totally no idea what's wrong with the configuration.
Things go back to normal if removing the appender declare.

logback-spring.xml

<configuration>
    <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
        <!-- encoders are assigned the type
             ch.qos.logback.classic.encoder.PatternLayoutEncoder by default -->
        <encoder>
            <pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
        </encoder>
    </appender>

    <appender name="aliyun" class="com.aliyun.openservices.log.logback.LoghubAppender">
        <!-- Required parameters -->
        <!-- Configure account and network  -->
        <endpoint>cn-shanghai-intranet.log.aliyuncs.com</endpoint>
        <accessKeyId>xxx</accessKeyId>
        <accessKeySecret>xxx</accessKeySecret>

        <project>edcs</project>
        <logStore>edcs-api-service</logStore>

        <!-- Configure sls -->
<!--        <springProfile name="daily">-->
<!--            <project>edcs</project>-->
<!--            <logStore>edcs-api-service</logStore>-->
<!--        </springProfile>-->
<!--        <springProfile name="prod">-->
<!--            <project>edcs</project>-->
<!--            <logStore>edcs-api-service</logStore>-->
<!--        </springProfile>-->
        <!-- Required parameters(end) -->

        <!-- Optional parameters -->
<!--        <topic>your topic</topic>-->
<!--        <source>your source</source>-->

        <!-- Optional parameters -->
        <totalSizeInBytes>104857600</totalSizeInBytes>
        <maxBlockMs>60000</maxBlockMs>
        <ioThreadCount>8</ioThreadCount>
        <batchSizeThresholdInBytes>524288</batchSizeThresholdInBytes>
        <batchCountThreshold>4096</batchCountThreshold>
        <lingerMs>2000</lingerMs>
        <retries>10</retries>
        <baseRetryBackoffMs>100</baseRetryBackoffMs>
        <maxRetryBackoffMs>100</maxRetryBackoffMs>

        <!-- Optional parameters -->
        <encoder>
            <pattern>%d %-5level [%thread] %logger{0}: %msg</pattern>
        </encoder>

        <!--  Optional parameters -->
        <timeFormat>yyyy-MM-dd'T'HH:mmZ</timeFormat>
        <!--  Optional parameters -->
        <timeZone>Asia/Shanghai</timeZone>
    </appender>

    <shutdownHook class="ch.qos.logback.core.hook.DelayingShutdownHook"/>
    <statusListener class="ch.qos.logback.core.status.OnConsoleStatusListener"/>

    <root level="debug">
        <appender-ref ref="STDOUT" />
        <appender-ref ref="aliyun" />
    </root>

    <springProfile name="default">
        <root level="debug">
            <appender-ref ref="STDOUT" />
            <appender-ref ref="aliyun" />
        </root>
        <logger name="org.hibernate.SQL" level="info"/>
        <logger name="org.hibernate.type" level="trace"/>
    </springProfile>

    <springProfile name="daily">
        <root level="debug">
            <appender-ref ref="STDOUT" />
        </root>
        <logger name="org.hibernate.SQL" level="info"/>
        <logger name="org.hibernate.type" level="trace"/>
    </springProfile>

    <springProfile name="prod">
        <root level="info">
            <appender-ref ref="STDOUT" />
        </root>
    </springProfile>
</configuration>

时区格式兼容

建议能兼容"GMT+08"这种时区格式,因为启动设置时区参数,如果是"GMT+08"这种的,没法将user.timezone属性应用到配置文件里。

jdk7使用0.1.18版本有问题

com.aliyun.openservices aliyun-log-logback-appender 0.1.18 com.aliyun.openservices aliyun-log-producer 0.3.8 jar-with-dependencies

因为项目中大量使用JDK7,在 0.1.18 版本时会出问题,错误信息如下:

at ch.qos.logback.core.util.DynamicClassLoadingException: Failed to instantiate type com.aliyun.openservices.log.logback.LoghubAppender

Caused by: java.lang.UnsupportedClassVersionError: com/aliyun/openservices/log/logback/LoghubAppender : Unsupported major.minor version 52.0

10:03:07,112 |-ERROR in ch.qos.logback.core.joran.spi.Interpreter@30:88 - ActionException in Action for tag [appender] ch.qos.logback.core.joran.spi.ActionException: ch.qos.logback.core.util.DynamicClassLoadingException: Failed to instantiate type com.aliyun.openservices.log.logback.LoghubAppender

logback 日志来源地址是否支持集群

source = [your source]
case1:我们后台应用是集群,两台机器,日志来源地址有必要写两个吗,如果有必要应该怎么写?
case2:同一台机器部署不同的tomcat应用,这样会不会造成混乱,到时候造成sls平台日志无法区分到底是那个应用的log?

ava.lang.NoSuchMethodError: ch.qos.logback.core.encoder.Encoder.encode

在com.aliyun.openservices.log.logback.LoghubAppender.appendEvent(LoghubAppender.java:127)

item.PushBack("log", new String(this.encoder.encode(eventObject)));

中encoder对象没有encode方法,只有一个doEncode方法?
造成错误
我的环境是SpringBoot,1.5.13.RELEASE

明显优势体现在哪?

单独做一个日志对接 SLS 相较于配置路径采集的优点是什么?前者会有网络传输开销,但根据文档,它提供了自定义 Entry 的查询功能。然而,在后者中,SlsContext 在日志隔格式中也很常见。所以这块,明显的优势在于减少了 SLS 的配置工作么?

Caused by: java.net.UnknownHostException: ${project-name}.cn-hangzhou.log.aliyuncs.com

com.aliyun.openservices.log.exception.LogException: Web request failed: ${project-name}.cn-hangzhou.log.aliyuncs.com
at com.aliyun.openservices.log.Client.SendData(Client.java:2144)
at com.aliyun.openservices.log.Client.PutLogs(Client.java:698)
at com.aliyun.openservices.aliyun.log.producer.internals.SendProducerBatchTask.sendProducerBatch(SendProducerBatchTask.java:82)
at com.aliyun.openservices.aliyun.log.producer.internals.SendProducerBatchTask.run(SendProducerBatchTask.java:57)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run$$$capture(FutureTask.java:266)
at java.util.concurrent.FutureTask.run(FutureTask.java)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
Caused by: com.aliyun.openservices.log.http.client.ClientException: ${project-name}.cn-hangzhou.log.aliyuncs.com
at com.aliyun.openservices.log.http.utils.ExceptionFactory.createNetworkException(ExceptionFactory.java:19)
at com.aliyun.openservices.log.http.comm.DefaultServiceClient.sendRequestCore(DefaultServiceClient.java:58)
at com.aliyun.openservices.log.http.comm.ServiceClient.sendRequestImpl(ServiceClient.java:100)
at com.aliyun.openservices.log.http.comm.ServiceClient.sendRequest(ServiceClient.java:81)
at com.aliyun.openservices.log.Client.SendData(Client.java:2127)
... 9 common frames omitted

是否会消耗大量的cpu和内存资源?

因为毕竟是要将日志通过网络传输到阿里云的日志服务,那么是否会消耗大量的日志cpu和内存资源呢?现在日志写入速度大概是每秒300条的日志。
特别是如果网络抖动,不稳定的情况下,会不会对应用服务影响很大?

-ERROR in com.aliyun.openservices.log.logback.LoghubAppender[INFO_PLUS] - Failed to send log,

按你们标准配置来的,出现了日志推送失败的报错,详细报错如下:
我用的 springboot 2.1.5版本整合的,logback日志
-ERROR in com.aliyun.openservices.log.logback.LoghubAppender[INFO_PLUS] - Failed to send log, project=app-log-center, logStore=xolo-job-executor, topic=test, source=, logItem=[com.aliyun.openservices.log.common.LogItem@239099d4] java.lang.InterruptedException
at java.lang.InterruptedException
at at java.util.concurrent.locks.AbstractQueuedSynchronizer.tryAcquireSharedNanos(AbstractQueuedSynchronizer.java:1326)
at at java.util.concurrent.Semaphore.tryAcquire(Semaphore.java:582)
at at com.aliyun.openservices.aliyun.log.producer.internals.LogAccumulator.doAppend(LogAccumulator.java:113)
at at com.aliyun.openservices.aliyun.log.producer.internals.LogAccumulator.append(LogAccumulator.java:84)
at at com.aliyun.openservices.aliyun.log.producer.LogProducer.send(LogProducer.java:385)
at at com.aliyun.openservices.aliyun.log.producer.LogProducer.send(LogProducer.java:286)
at at com.aliyun.openservices.log.logback.LoghubAppender.appendEvent(LoghubAppender.java:171)
at at com.aliyun.openservices.log.logback.LoghubAppender.append(LoghubAppender.java:117)
at at ch.qos.logback.core.UnsynchronizedAppenderBase.doAppend(UnsynchronizedAppenderBase.java:84)
at at ch.qos.logback.core.spi.AppenderAttachableImpl.appendLoopOnAppenders(AppenderAttachableImpl.java:51)
at at ch.qos.logback.classic.Logger.appendLoopOnAppenders(Logger.java:270)
at at ch.qos.logback.classic.Logger.callAppenders(Logger.java:257)
at at ch.qos.logback.classic.Logger.buildLoggingEventAndAppend(Logger.java:421)
at at ch.qos.logback.classic.Logger.filterAndLog_1(Logger.java:398)
at at ch.qos.logback.classic.Logger.info(Logger.java:583)
at at com.xxl.job.core.thread.JobThread.run(JobThread.java:216)

启动超时

19:55:19,069 |-ERROR in com.aliyun.openservices.log.logback.LoghubAppender[aliyun-error] - Failed to send log, project=app-sas-log, logStore=app-logstore-error, topic=apu-error, source=, logItem=[com.aliyun.openservices.log.common.LogItem@19d39d9b] com.aliyun.openservices.aliyun.log.producer.errors.TimeoutException: failed to acquire memory within the configured max blocking time 0 ms
at com.aliyun.openservices.aliyun.log.producer.errors.TimeoutException: failed to acquire memory within the configured max blocking time 0 ms
at at com.aliyun.openservices.aliyun.log.producer.internals.LogAccumulator.doAppend(LogAccumulator.java:117)
at at com.aliyun.openservices.aliyun.log.producer.internals.LogAccumulator.append(LogAccumulator.java:84)
at at com.aliyun.openservices.aliyun.log.producer.LogProducer.send(LogProducer.java:385)
at at com.aliyun.openservices.aliyun.log.producer.LogProducer.send(LogProducer.java:286)
at at com.aliyun.openservices.log.logback.LoghubAppender.appendEvent(LoghubAppender.java:171)
at at com.aliyun.openservices.log.logback.LoghubAppender.append(LoghubAppender.java:117)
at at ch.qos.logback.core.UnsynchronizedAppenderBase.doAppend(UnsynchronizedAppenderBase.java:84)
at at ch.qos.logback.core.spi.AppenderAttachableImpl.appendLoopOnAppenders(AppenderAttachableImpl.java:51)
at at ch.qos.logback.classic.Logger.appendLoopOnAppenders(Logger.java:270)
at at ch.qos.logback.classic.Logger.callAppenders(Logger.java:257)
at at ch.qos.logback.classic.Logger.buildLoggingEventAndAppend(Logger.java:421)
at at ch.qos.logback.classic.Logger.filterAndLog_0_Or3Plus(Logger.java:383)
at at ch.qos.logback.classic.Logger.log(Logger.java:765)
at at org.apache.commons.logging.LogAdapter$Slf4jLocationAwareLog.debug(LogAdapter.java:468)
at at org.apache.http.impl.conn.Wire.wire(Wire.java:73)
at at org.apache.http.impl.conn.Wire.output(Wire.java:111)
at at org.apache.http.impl.conn.LoggingOutputStream.write(LoggingOutputStream.java:73)
at at org.apache.http.impl.io.SessionOutputBufferImpl.streamWrite(SessionOutputBufferImpl.java:124)
at at org.apache.http.impl.io.SessionOutputBufferImpl.flushBuffer(SessionOutputBufferImpl.java:136)
at at org.apache.http.impl.io.SessionOutputBufferImpl.write(SessionOutputBufferImpl.java:167)
at at org.apache.http.impl.io.ContentLengthOutputStream.write(ContentLengthOutputStream.java:113)
at at com.aliyun.openservices.log.http.comm.RepeatableInputStreamEntity$NoAutoClosedInputStreamEntity.writeTo(RepeatableInputStreamEntity.java:108)
at at com.aliyun.openservices.log.http.comm.RepeatableInputStreamEntity.writeTo(RepeatableInputStreamEntity.java:52)
at at org.apache.http.impl.DefaultBHttpClientConnection.sendRequestEntity(DefaultBHttpClientConnection.java:156)
at at org.apache.http.impl.conn.CPoolProxy.sendRequestEntity(CPoolProxy.java:152)
at at org.apache.http.protocol.HttpRequestExecutor.doSendRequest(HttpRequestExecutor.java:238)
at at org.apache.http.protocol.HttpRequestExecutor.execute(HttpRequestExecutor.java:123)
at at org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:272)
at at org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:186)
at at org.apache.http.impl.execchain.RedirectExec.execute(RedirectExec.java:110)
at at org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:185)
at at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:83)
at at com.aliyun.openservices.log.http.comm.TimeoutServiceClient$HttpRequestTask.call(TimeoutServiceClient.java:128)
at at com.aliyun.openservices.log.http.comm.TimeoutServiceClient$HttpRequestTask.call(TimeoutServiceClient.java:117)
at at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at at java.lang.Thread.run(Thread.java:748)

日志缺失问题

sls日志缺失 pic
message中的信息展示不全,正常本地打印的时候最后还有另起一行的日志的,但是sls中感觉像是少了换行后的日志,最后那一行是最重要的错误原因,结果都没打印出来

能否自己来控制显示那几列日志信息

现在有一下几个显示的信息,我能不能控制只显示message,或者能不能我自己添加一个或多个列。比如报的这个错误日志是属于那一大分类,添加一列Category
level:
location:
message:
thread:
time:

还有一个问题:我不可以在配置文件中定义自己显示的message格式吗???好像不支持encoder→pattern属性

性能非常差,并且会阻塞用户线程

  1. 不应该调用 event.getCallerData(),爬栈的消耗极大。要不要调用这个方法,logback 自己会根据日志格式中有没有 %line自行判断。
  2. 不应该使用new String(this.encoder.encode(eventObject)),这条语句会导致 layout 的生成的 string 日志内容转成 byte[] 再转成 string,多复制了两份。
  3. 不应该直接调用 producer.send(),该方法在获取锁的时候会阻塞用户线程,当日志服务网络不稳定或达到上限时,用户线程默认会等待 60s。此处应该异步。

logback.xml文件冲突.

src/main/resources/ 里的logback.xml是不是应该拿掉. 否则会与本地代码的logback.xml文件冲突.

下载代码运行报错

下载了这个开源包,使用 Idea 环境运行,
配置完成 logback-test.xml 的参数后 ,运行 LogbackAppenderExample 程序,
报这个错。
请问一下,是我参数没有配置对吗,还是其他什么原因呢。

15:15:10,634 |-INFO in ch.qos.logback.core.joran.action.ShutdownHookAction - About to instantiate shutdown hook of type [ch.qos.logback.core.hook.DelayingShutdownHook]
15:15:10,643 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - About to instantiate appender of type [com.aliyun.openservices.log.logback.LoghubAppender]
15:15:10,656 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - Naming appender as [loghubAppender1]
15:15:10,721 |-ERROR in com.aliyun.openservices.log.logback.LoghubAppender[loghubAppender1] - Failed to start LoghubAppender. java.lang.NullPointerException: endpoint cannot be null
at java.lang.NullPointerException: endpoint cannot be null
at at com.aliyun.openservices.aliyun.log.producer.ProjectConfig.(ProjectConfig.java:48)
at at com.aliyun.openservices.log.logback.LoghubAppender.buildProjectConfig(LoghubAppender.java:93)
at at com.aliyun.openservices.log.logback.LoghubAppender.createProducer(LoghubAppender.java:86)
at at com.aliyun.openservices.log.logback.LoghubAppender.doStart(LoghubAppender.java:81)
at at com.aliyun.openservices.log.logback.LoghubAppender.start(LoghubAppender.java:69)
at at ch.qos.logback.core.joran.action.AppenderAction.end(AppenderAction.java:90)
at at ch.qos.logback.core.joran.spi.Interpreter.callEndAction(Interpreter.java:309)

=========logback-test.xml 内容


<appender name="aliyun" class="com.aliyun.openservices.log.logback.LoghubAppender">
    <!--必选项-->
    <!-- 账号及网络配置 -->

    <endpoint>hello-log2.cn-huhehaote.log.aliyuncs.com</endpoint>
    <accessKeyId>xxxx</accessKeyId>
    <accessKeySecret>xxxxxzqyVN</accessKeySecret>

    <!-- sls 项目配置 -->
    <project>hello-log2</project>
    <logStore>hello-log2</logStore>

    <!-- 可选项 详见 '参数说明'-->
    <totalSizeInBytes>104857600</totalSizeInBytes>
    <maxBlockMs>60000</maxBlockMs>
    <ioThreadCount>8</ioThreadCount>
    <batchSizeThresholdInBytes>524288</batchSizeThresholdInBytes>
    <batchCountThreshold>4096</batchCountThreshold>
    <lingerMs>2000</lingerMs>
    <retries>10</retries>
    <baseRetryBackoffMs>100</baseRetryBackoffMs>
    <maxRetryBackoffMs>100</maxRetryBackoffMs>

    <!-- 可选项 设置时间格式 -->
    <timeFormat>yyyy-MM-dd'T'HH:mmZ</timeFormat>
    <timeZone>GMT+08</timeZone>

    <encoder>
        <pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger - %msg</pattern>
    </encoder>
    <mdcFields>THREAD_ID,MDC_KEY</mdcFields>
</appender>

<!-- 可用来获取StatusManager中的状态
<statusListener class="ch.qos.logback.core.status.OnConsoleStatusListener"/>
-->
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
    <!-- encoders are assigned the type ch.qos.logback.classic.encoder.PatternLayoutEncoder
        by default -->
    <encoder>
        <pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger - %msg %n</pattern>
    </encoder>
</appender>

<!-- 解决debug模式下循环发送的问题 -->
<logger name="org.apache.http.impl.conn.Wire" level="WARN" />

<root>
    <level value="WARN"/>
    <appender-ref ref="aliyun"/>
    <appender-ref ref="STDOUT"/>
</root>

producer0.3.0的支持

请问下什么时候能支持到log-producer 0.3.0,这个版本的producer初始化api完全改了。引入新包以后run不起来。被迫要降级回去

NoSuchMethodError

maven dependency:

com.google.protobuf
protobuf-java
2.5.0


com.aliyun.openservices
aliyun-log-logback-appender
0.1.15

case:

Java HotSpot(TM) 64-Bit Server VM warning: CMSFullGCsBeforeCompaction is deprecated and will likely be removed in a future release.
Exception in thread "main" java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:48)
at org.springframework.boot.loader.Launcher.launch(Launcher.java:87)
at org.springframework.boot.loader.Launcher.launch(Launcher.java:50)
at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:51)
Caused by: java.lang.NoSuchMethodError: com.google.common.hash.Hashing.farmHashFingerprint64()Lcom/google/common/hash/HashFunction;
at com.aliyun.openservices.aliyun.log.producer.internals.Utils.generateProducerHash(Utils.java:31)
at com.aliyun.openservices.aliyun.log.producer.LogProducer.(LogProducer.java:77)
at com.aliyun.openservices.log.logback.LoghubAppender.createProducer(LoghubAppender.java:89)
at com.aliyun.openservices.log.logback.LoghubAppender.doStart(LoghubAppender.java:82)
at com.aliyun.openservices.log.logback.LoghubAppender.start(LoghubAppender.java:70)
at ch.qos.logback.core.joran.action.AppenderAction.end(AppenderAction.java:90)
at ch.qos.logback.core.joran.spi.Interpreter.callEndAction(Interpreter.java:309)
at ch.qos.logback.core.joran.spi.Interpreter.endElement(Interpreter.java:193)
at ch.qos.logback.core.joran.spi.Interpreter.endElement(Interpreter.java:179)
at ch.qos.logback.core.joran.spi.EventPlayer.play(EventPlayer.java:62)
at ch.qos.logback.core.joran.GenericConfigurator.doConfigure(GenericConfigurator.java:165)
at ch.qos.logback.core.joran.GenericConfigurator.doConfigure(GenericConfigurator.java:152)
at ch.qos.logback.core.joran.GenericConfigurator.doConfigure(GenericConfigurator.java:110)
at ch.qos.logback.core.joran.GenericConfigurator.doConfigure(GenericConfigurator.java:53)
at ch.qos.logback.classic.util.ContextInitializer.configureByResource(ContextInitializer.java:75)
at ch.qos.logback.classic.util.ContextInitializer.autoConfig(ContextInitializer.java:150)
at org.slf4j.impl.StaticLoggerBinder.init(StaticLoggerBinder.java:84)
at org.slf4j.impl.StaticLoggerBinder.(StaticLoggerBinder.java:55)
at org.slf4j.LoggerFactory.bind(LoggerFactory.java:150)
at org.slf4j.LoggerFactory.performInitialization(LoggerFactory.java:124)
at org.slf4j.LoggerFactory.getILoggerFactory(LoggerFactory.java:412)
at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:357)
at org.apache.commons.logging.impl.SLF4JLogFactory.getInstance(SLF4JLogFactory.java:156)
at org.apache.commons.logging.impl.SLF4JLogFactory.getInstance(SLF4JLogFactory.java:132)
at org.apache.commons.logging.LogFactory.getLog(LogFactory.java:274)
at org.springframework.boot.SpringApplication.(SpringApplication.java:190)
at com.sjx.gbck.cloudpos.core.soa.SoaCoreApplication.main(SoaCoreApplication.java:57)

Logback 自动搜索并引用包中未配置的 logback.xml

使用 Spring Boot 2.0 从 Gradle 引入该库,且未在项目中配置 logback.xml (如单元测试时)的时候,会自动引入包中的 logback.xml。又因这个文件是样板文件尚未被正确配置,会造成报错:

2:53:06,194 |-INFO in ch.qos.logback.classic.LoggerContext[default] - Found resource [logback.xml] at [jar:file:/xxx/.gradle/caches/modules-2/files-2.1/com.aliyun.openservices/aliyun-log-logback-appender/0.1.16/bfd55f2db8acd25219b6e3a9939bd43e96ade9e9/aliyun-log-logback-appender-0.1.16.jar!/logback.xml]
12:53:06,202 |-INFO in ch.qos.logback.core.joran.spi.ConfigurationWatchList@295cf707 - URL [jar:file:/C:/Users/xjoew/.gradle/caches/modules-2/files-2.1/com.aliyun.openservices/aliyun-log-logback-appender/0.1.16/bfd55f2db8acd25219b6e3a9939bd43e96ade9e9/aliyun-log-logback-appender-0.1.16.jar!/logback.xml] is not of type file
12:53:06,311 |-INFO in ch.qos.logback.classic.joran.action.ConfigurationAction - debug attribute not set
12:53:06,314 |-INFO in ch.qos.logback.core.joran.action.ShutdownHookAction - About to instantiate shutdown hook of type [ch.qos.logback.core.hook.DelayingShutdownHook]
12:53:06,321 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - About to instantiate appender of type [com.aliyun.openservices.log.logback.LoghubAppender]
12:53:06,335 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - Naming appender as [loghubAppender1]
12:53:06,371 |-ERROR in com.aliyun.openservices.log.logback.LoghubAppender[loghubAppender1] - Failed to start LoghubAppender. java.lang.NullPointerException: endpoint cannot be null
	at java.lang.NullPointerException: endpoint cannot be null
	at 	at com.aliyun.openservices.aliyun.log.producer.ProjectConfig.<init>(ProjectConfig.java:48)
	at 	at com.aliyun.openservices.log.logback.LoghubAppender.buildProjectConfig(LoghubAppender.java:93)
	at 	at com.aliyun.openservices.log.logback.LoghubAppender.createProducer(LoghubAppender.java:86)
	at 	at com.aliyun.openservices.log.logback.LoghubAppender.doStart(LoghubAppender.java:81)
	at 	at com.aliyun.openservices.log.logback.LoghubAppender.start(LoghubAppender.java:69)
	at 	at ch.qos.logback.core.joran.action.AppenderAction.end(AppenderAction.java:90)

能否将此文件重命名为不能被自动搜索到的文件名,或放在 test 模块中,又或者在构建的时候不将此文件打包?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.