美文网首页
neo4j 日志的时区问题

neo4j 日志的时区问题

作者: wangliang938 | 来源:发表于2017-05-27 15:21 被阅读353次

官网是使用新的perl脚本来完成的
1,新建 perl-log.pl脚本


Paste_Image.png

2,脚本内容

#!/usr/bin/perl -w
use strict;
use Time::Local;  #needed for timegm()

my $file = $ARGV[0] or die "USAGE: $0 <filename>\n";

open(my $data, '<', $file) or die "Could not open '$file' $!\n";

while (my $line = <$data>) {
  # where a line might start as
  # 2017-01-11 23:22:28.372+0000 INFO ... .... ....
  chomp $line;
  # check to make sure the line begins with a YYYY-MM-DD HH
  if ( $line =~ /\d\d\d\d-\d\d-\d\d \d\d/ ) {
          my $newstring = UTC2LocalString($line);
          print "$newstring\n";
  }
  else {
      print "$line\n";
  }
}


sub UTC2LocalString
{
  # below attributed to Marshall at http://www.perlmonks.org/?node_id=873435
  my $t = shift;
  my ($datehour, $rest) = split(/:/,$t,2);
  #   $datehour will represent YYYY-MM-DD HH  (i.e. 2017-01-14 12)
  #   $rest represents the rest of the line after
  #   and this will reassemble and return $datehour (adjusted) + $rest
  my ($year, $month, $day, $hour) =
      $datehour =~ /(\d+)-(\d\d)-(\d\d)\s+(\d\d)/;

  #  proto: $time = timegm($sec,$min,$hour,$mday,$mon,$year);
  my $epoch = timegm (0,0,$hour,$day,$month-1,$year);

  #  proto: ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) =
  #          localtime(time);
  my ($lyear,$lmonth,$lday,$lhour,$isdst) =
            (localtime($epoch))[5,4,3,2,-1];

  $lyear += 1900;  # year is 1900 based
  $lmonth++;       # month number is zero based
  #print "isdst: $isdst\n"; #debug flag day-light-savings time
  return ( sprintf("%04d-%02d-%02d %02d:%s",
           $lyear,$lmonth,$lday,$lhour,$rest) );
}

3,赋执行的权限,使用的时候 ./perl-log.pl <日志地址>
4,效果
以前的

Paste_Image.png

修改后的(虽然时区显示的有问题,但是时间已经改过来了。不影响观看)

Paste_Image.png

相关文章

  • neo4j 日志的时区问题

    官网是使用新的perl脚本来完成的1,新建 perl-log.pl脚本 2,脚本内容 3,赋执行的权限,使用的时...

  • 本地运行Neo4j的日志优化

    译者言: 本文重点介绍Neo4j的日志配置中关于日志文件大小的控制选项,并给出在本地运行Neo4j时推荐的日志配置...

  • Neo4j知识库:初识Neo4j查询日志分析器

    Neo4j知识库:初识Neo4j查询日志分析器 原文链接: https://medium.com/neo4j/me...

  • Druid-Druid中修改日志中的时区

    基于apache-druid-0.17 概述 部署好druid集群后,发现druid的日志中时区与服务器的时区存在...

  • Java 中的时区理解和处理

    本文内容:1,时区了解一下2,产生时区的原因3,常用时间类,哪些是有会导致时区问题4,开发中如何避免产生时区问题 ...

  • linux 命令

    ssh 查看正在进行的ssh链接 查看linux登陆日志 时区、时间、日期 查看当前时区 修改设置Linux服务器...

  • 时区问题

    //获取格林威治标准时间public void getGMTTime() {//mothed 2TimeZone ...

  • 时区问题

    2020-11-10 00:00:00 +0000 ---> GMT+0 尼林格日标准时间 也就是 0时区。 ...

  • jar包启动时,为jvm设置时区

    把项目布到环境上,jvm时区不正确,导致日志和项目的时间都不是我们自己的默认时区 java -jar -Duser...

  • Mysql更新时区表

    时区问题 Django项目做了数据库迁移后有时候出现时区上的问题,例如django项目中设置的时区是TIME_Z...

网友评论

      本文标题:neo4j 日志的时区问题

      本文链接:https://www.haomeiwen.com/subject/vceqfxtx.html