npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

ezdev-log

v1.1.4

Published

日志展示模块

Downloads

3

Readme

日志管理

日志管理模块主要通过elasticsearch作为储存,logstash作为传输媒介,实现了系统日志与访问日志的储存与查询

功能说明

  • 操作记录--对所有模块的操作记录进行查询追溯
  • 日志采集--对系统的访问日志与系统日志进行采集

使用说明

安装elastaicsearch

版本要求:2.4.5

下载地址

1.打开\config\elasticsearch.yml

添加配置

network.host: 0.0.0.0

2.启动:\bin\elasticsearch.bat


安装logstash

版本要求:5.4.33

下载地址

1.修改工程ezdev-common\ezdev-common-log\src\main\resources\logstash\logstash.config

input {
 redis {
  codec => json
  host => "192.168.1.164"
  port => 6379
  key => "logstash"
  data_type => "list"
 }
}
output{
	elasticsearch{
		hosts => ["localhost:9200"]
		index => "logstash"
	}
}

input.redis.host => 实际redis地址

input.redis.port => 实际redis端口

output.elasticsearch.hosts => 实际es地址

2.把logstash.config拷贝到logstash\bin目录下

3.启动:\bin\logstash -f logstash.config


安装kibana(如无系统日志查询需要,可略过)

版本要求:4.6.4

下载地址

1.修改\config\kibana.yml

添加elasticsearch.url: 实际es地址

2.启动:\bin\kibana.bat


安装sentinl监控插件(如无系统监控需要,可略过)

版本要求:4.6.4(必须与kibana版本对应)

下载地址

1.安装命令:\bin\kibana plugin -i sentinl -u file:D:\elk-stack\kibana-4.6.4-windows-x86\bin\sentinl.zip

粗体部分替换为实际位置

2.修改kibana\config\kibana.yml

在最后添加如下内容

    sentinl:  
      settings:  
        email:  
          active: true  
          user: [email protected]  //邮箱账号  
          password: xxxxxxx  //邮箱密码(第三方登录密码)  
          host: smtp.server.com  // 邮箱smtp 服务器地址  
          ssl: true  
        report:  
          active: true  
          tmp_path: /tmp/  

日志模块使用

1.在pom.xml引入

    <dependency>
        <groupId>com.chrtc.ezdev</groupId>
        <artifactId>ezdev-common-log</artifactId>
    </dependency>

前端模块安装展示模块

npm install ezdev-log

2.在\resources下添加文件logback.xml

    <?xml version="1.0" encoding="UTF-8"?>
    <configuration debug="false">
    <include resource="org/springframework/boot/logging/logback/base.xml" />

    <appender name="LOGSTASH" class="com.cwbase.logback.RedisAppender">
        <!-- redis地址 -->
        <host>192.168.1.45</host>
        <!-- redis端口 -->
        <port>6379</port>
        <key>logstash</key>
        <password></password>
        <database>0</database>
        <timeout>2000</timeout>
        <type>@{type}</type>
        <mdc>true</mdc>
        <additionalField>
            <key>module</key>
            <value>@{module}</value>
        </additionalField>
        <additionalField>
            <key>operation</key>
            <value>@{operation}</value>
        </additionalField>
        <additionalField>
            <key>time</key>
            <value>@{time}</value>
        </additionalField>
        <additionalField>
            <key>user</key>
            <value>@{user}</value>
        </additionalField>
        <additionalField>
            <key>ip</key>
            <value>@{ip}</value>
        </additionalField>
        <additionalField>
            <key>uri</key>
            <value>@{uri}</value>
        </additionalField>
    </appender>
    <appender name="ASYNC" class="ch.qos.logback.classic.AsyncAppender">
        <appender-ref ref="LOGSTASH" />
    </appender>
    <root level="INFO">
        <appender-ref ref="CONSOLE" />
        <appender-ref ref="FILE" />
        <appender-ref ref="ASYNC" />
    </root>
    </configuration>

3.修改\resources\application.properties添加日志与es数据源配置如下

# logging config
logging.config=classpath:logback.xml

# elasticsearch config
spring.data.elasticsearch.cluster-nodes=192.168.10.112:9300
spring.data.elasticsearch.local=false
spring.data.elasticsearch.repositories.enabled=true

nginx配置

1.在反向代理中如下配置解决nginx环境中tomcat无法获取真实访问IP的问题

        location /xxx {
            proxy_pass       http://localhost:8080;

            proxy_set_header  Host $http_host;
            proxy_set_header  X-Real-IP  $remote_addr;
            proxy_set_header  X-Forwarded-For  $proxy_add_x_forwarded_for;
        }

备注:

proxy_set_header  Host                    $http_host;            # 将当前Host头域值填充成客户端地址
proxy_set_header  X-Real-IP               $remote_addr;                # 真实用户IP
proxy_set_header  X-Forwarded-For         $proxy_add_x_forwarded_for;    # 代理路由信息,此处取ip有安全隐患

API文档

注释 | 属性 | 说明 ---|---|--- @EzdevModule | name|在类上使用,设置name属性作为日志中模块内容 @EzdevOperation | name |在方法上使用,设置name属性作为日志中操作内容 @EzdevParam | name|在方法参数中使用,设置name属性作为日志中参数的名称