dcos - docker的日志收集

3 篇文章 0 订阅
1 篇文章 0 订阅

这里写图片描述

java日志配置

<?xml version="1.0" encoding="UTF-8"?>
<!--
    Copyright 2010-2011 The myBatis Team
    Licensed under the Apache License, Version 2.0 (the "License");
    you may not use this file except in compliance with the License.
    You may obtain a copy of the License at
        http://www.apache.org/licenses/LICENSE-2.0
    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.
-->
<configuration debug="false">
    <!--定义日志文件的存储地址 勿在 LogBack 的配置中使用相对路径-->
    <property name="LOG_HOME" value="/data/logs/1232"/>
    <!-- 控制台输出 -->
    <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
        <Encoding>UTF-8</Encoding>
        <layout class="ch.qos.logback.classic.PatternLayout">
            <!--格式化输出:%d表示日期,%thread表示线程名,%-5level:级别从左显示5个字符宽度%msg:日志消息,%n是换行符-->
            <pattern>[%-5level] %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %logger{500} - %msg%n</pattern>
        </layout>
    </appender>
    <!-- 按照每天生成错误日志文件 -->

    <appender name="ERROR_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
        <Encoding>UTF-8</Encoding>
    <file>${LOG_HOME}/123.error.log</file>
    <rollingPolicy class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy"> 
      <fileNamePattern>${LOG_HOME}/123.%i.error.log</fileNamePattern> 
      <minIndex>1</minIndex> 
      <maxIndex>10000</maxIndex> 
    </rollingPolicy> 
    <triggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy"> 
      <maxFileSize>1MB</maxFileSize> 
    </triggeringPolicy> 
        <encoder>
            <pattern>[%-5level] %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %logger{500} - %msg%n</pattern>
        </encoder>
    </appender>

    <appender name="INFO_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
        <Encoding>UTF-8</Encoding>
        <file>${LOG_HOME}/123.info.log</file>
    <rollingPolicy class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy">
      <fileNamePattern>${LOG_HOME}/123.%i.info.log</fileNamePattern>
      <minIndex>1</minIndex>
      <maxIndex>10000</maxIndex>
    </rollingPolicy>
    <triggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
      <maxFileSize>1MB</maxFileSize>
    </triggeringPolicy>
        <encoder>
            <pattern>[%-5level] %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %logger{500} - %msg%n</pattern>
        </encoder>
    </appender>

<configuration debug="true">
    <appender name="loggly" class="ch.qos.logback.classic.net.SyslogAppender">
        <syslogHost>localhost</syslogHost>
        <facility>SYSLOG</facility>
        <port>514</port>
        <suffixPattern>java %d{ISO8601,UTC} %p %t %c{0}.%M - %m%n</suffixPattern>
    </appender>
   <root level="info">
       <appender-ref ref="loggly" />
   </root>
</configuration>



    <!-- 本工程的日志级别 -->
    <logger name="net.123.server" level="INFO"/>
    <logger name="org.springframework.amqp" level="WARN"/>
    <!-- show parameters for hibernate sql 专为 Hibernate 定制 -->
    <logger name="org.hibernate.ptype.descriptor.sql.BasicBinder" level="INFO"/>
    <logger name="org.hibernate.ptype.descriptor.sql.BasicExtractor" level="INFO"/>
    <logger name="org.hibernate.SQL" level="INFO"/>
    <logger name="org.hibernate.engine.QueryParameters" level="INFO"/>
    <logger name="org.hibernate.engine.query.HQLQueryPlan" level="INFO"/>
    <!--myibatis log configure-->
    <logger name="java.sql.Connection" level="INFO"/>
    <logger name="java.sql.Statement" level="INFO"/>
    <logger name="java.sql.PreparedStatement" level="INFO"/>

    <logger name="org.apache.commons" level="INFO"/>
    <!-- 日志输出级别 -->
    <root level="INFO">
        <appender-ref ref="STDOUT"/>
        <appender-ref ref="INFO_FILE"/>
        <appender-ref ref="ERROR_FILE"/>
    </root>
</configuration>

docker里面的syslog-ng进程

[root@d390c7582ad7 syslog-ng]# cat syslog-ng.conf 
@version:3.2

# syslog-ng configuration file.
#
# This should behave pretty much like the original syslog on RedHat. But
# it could be configured a lot smarter.
#
# See syslog-ng(8) and syslog-ng.conf(5) for more information.
#

options {
    flush_lines (0);
    time_reopen (10);
    log_fifo_size (1000);
    long_hostnames (off);
    use_dns (no);
    use_fqdn (no);
    create_dirs (no);
    keep_hostname (yes);
};

options { 
    long_hostnames(off); flush_lines(0); use_dns(no); use_fqdn(no);
          owner("root"); group("adm"); perm(0640); stats_freq(0);
          bad_hostname("^gconfd$");
};

source test{ 
    file("/data/logs/123-123/xcloud-cs.2016-11-24_0.error.log" follow_freq(1) program_override("123-123.error"));
    file("/data/logs/123-123/123-123.2016-11-24_0.info.log" follow_freq(1) program_override("123-123.info"));
};
destination test { 
    syslog("192.168.126.15" transport("tcp") port(5555) template("$MESSAGE\n"));
};

log { 
    source(test); 
        destination(test); 
};

syslog-ng server进程配置

[root@t15 conf.d]# cat a.conf 
@version: 3.5

source log5555 {
    syslog(ip(0.0.0.0) port(5555));
};

destination log5555 { 
    file("/var/log/syslog-ng/$PROGRAM/${S_MONTH}${S_DAY}/${HOST}.${SOURCEIP}.log"); 
};
log{
    source(log5555);destination(log5555);
};
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值