logging模块处理时间为什么会差距个小时,有谁遇到过吗?

classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

logging模块处理时间为什么会差距个小时,有谁遇到过吗?

Arui Zen
程序里面用了logging,默认的asctime输出的时间早了8个小时,比如现在是15:45,它输出的是05:45,我的代码:
我已经显式指定了datefmt为默认格式,

logger=logging.getLogger('IMR')
logger.setLevel(logging.DEBUG)
imrFormatter = logging.Formatter('%(asctime)s |##| %(message)s',datefmt='%Y-%m-%d %H:%M:%S')


平台:
ubuntu server 7.10
时区: Asia/Shanghai

用python查看:
>>> import time
>>> time.asctime()
'Mon Jan  7 15:48:34 2008'
>>>  

然后程序的输出还是类似于
2008-01-07 07:33:39 |##|
这样的格式,整整早了8小时,

在另一台RHEL上运行也是一样的情况,,,,
有谁遇到过类似情况吗?请指教.

--

DJ
_______________________________________________
python-chinese
Post: send [hidden email]
Subscribe: send subscribe to [hidden email]
Unsubscribe: send unsubscribe to  [hidden email]
Detail Info: http://python.cn/mailman/listinfo/python-chinese
Reply | Threaded
Open this post in threaded view
|

Re: logging模块处理时间为什么会差距个小时,有谁遇到过吗?

@@-2
时区 时差?

On 1/7/08, Arui Zen <[hidden email]> wrote:
程序里面用了logging,默认的asctime输出的时间早了8个小时,比如现在是15:45,它输出的是05:45,我的代码:
我已经显式指定了datefmt为默认格式,

logger=logging.getLogger ('IMR')
logger.setLevel(logging.DEBUG)
imrFormatter = logging.Formatter('%(asctime)s |##| %(message)s',datefmt='%Y-%m-%d %H:%M:%S')


平台:
ubuntu server 7.10
时区: Asia/Shanghai

用python查看:
>>> import time
>>> time.asctime()
'Mon Jan  7 15:48:34 2008'
>>>  

然后程序的输出还是类似于
2008-01-07 07:33:39 |##|
这样的格式,整整早了8小时,

在另一台RHEL上运行也是一样的情况,,,,
有谁遇到过类似情况吗?请指教.

--

DJ

_______________________________________________
python-chinese
Post: send [hidden email]
Subscribe: send subscribe to [hidden email]
Unsubscribe: send unsubscribe to  [hidden email]
Detail Info: <a onclick="return top.js.OpenExtLink(window,event,this)" href="http://python.cn/mailman/listinfo/python-chinese" target="_blank"> http://python.cn/mailman/listinfo/python-chinese


_______________________________________________
python-chinese
Post: send [hidden email]
Subscribe: send subscribe to [hidden email]
Unsubscribe: send unsubscribe to  [hidden email]
Detail Info: http://python.cn/mailman/listinfo/python-chinese
Reply | Threaded
Open this post in threaded view
|

RE: logging模块处理时间为什么会差距个小时,有谁遇到过吗?

tairan wang

1. 2台机器?
2. 如果是2台机器,Server 的时区是什么, Client 的时区又是什么?



Date: Mon, 7 Jan 2008 16:33:12 +0800
From: [hidden email]
To: [hidden email]
Subject: Re: [python-chinese] logging模块处理时间为什么会差距个小时,有谁遇到过吗?

时区 时差?

On 1/7/08, Arui Zen <[hidden email]> wrote:
程序里面用了logging,默认的asctime输出的时间早了8个小时,比如现在是15:45,它输出的是05:45,我的代码:
我已经显式指定了datefmt为默认格式,

logger=logging.getLogger ('IMR')
logger.setLevel(logging.DEBUG)
imrFormatter = logging.Formatter('%(asctime)s |##| %(message)s',datefmt='%Y-%m-%d %H:%M:%S')


平台:
ubuntu server 7.10
时区: Asia/Shanghai

用python查看:
>>> import time
>>> time.asctime()
'Mon Jan  7 15:48:34 2008'
>>>  

然后程序的输出还是类似于
2008-01-07 07:33:39 |##|
这样的格式,整整早了8小时,

在另一台RHEL上运行也是一样的情况,,,,
有谁遇到过类似情况吗?请指教.

--

DJ

_______________________________________________
python-chinese
Post: send [hidden email]
Subscribe: send subscribe to [hidden email]
Unsubscribe: send unsubscribe to  [hidden email]
Detail Info: http://python.cn/mailman/listinfo/python-chinese



Express yourself instantly with MSN Messenger! MSN Messenger
_______________________________________________
python-chinese
Post: send [hidden email]
Subscribe: send subscribe to [hidden email]
Unsubscribe: send unsubscribe to  [hidden email]
Detail Info: http://python.cn/mailman/listinfo/python-chinese
Reply | Threaded
Open this post in threaded view
|

Re: logging模块处理时间为什么会差距个小时,有谁遇到过吗?

GoodGoodStudy&DayDayUp
In reply to this post by Arui Zen
看下你的 logging.Formatter.converter  和imrFormatter.converter 是不是localtime 。


> Message: 2
> Date: Mon, 7 Jan 2008 15:50:24 +0800
> From: "Arui Zen" <[hidden email]>
> Subject: [python-chinese]
>         logging模块处理时间为什么会差距个小时,有谁遇到过吗?
>
> To: [hidden email]
> Cc: [hidden email]
> Message-ID:
>         <[hidden email]>
> Content-Type: text/plain; charset="gb2312"
>
> 程序里面用了logging,默认的asctime输出的时间早了8个小时,比如现在是15:45,它输出的是05:45,我的代码:
> 我已经显式指定了datefmt为默认格式,
>
> logger=logging.getLogger('IMR')
> logger.setLevel(logging.DEBUG)
> imrFormatter = logging.Formatter('%(asctime)s |##|
> %(message)s',datefmt='%Y-%m-%d %H:%M:%S')
>
>
> 平台:
> ubuntu server 7.10
> 时区: Asia/Shanghai
>
> 用python查看:
> >>> import time
> >>> time.asctime()
> 'Mon Jan  7 15:48:34 2008'
> >>>
>
> 然后程序的输出还是类似于
> 2008-01-07 07:33:39 |##|
> 这样的格式,整整早了8小时,
>
> 在另一台RHEL上运行也是一样的情况,,,,
> 有谁遇到过类似情况吗?请指教.
>
> --
>
> DJ


--
THINK big, DO small.
_______________________________________________
python-chinese
Post: send [hidden email]
Subscribe: send subscribe to [hidden email]
Unsubscribe: send unsubscribe to  [hidden email]
Detail Info: http://python.cn/mailman/listinfo/python-chinese
Reply | Threaded
Open this post in threaded view
|

Re: logging模块处理时间为什么会差距个小时,有谁遇到过吗?

樊帆
中国的时区是东八区,和标准时间8个小时时差

在 08-1-7,GoodGoodStudy&DayDayUp<[hidden email]> 写道:

> 看下你的 logging.Formatter.converter  和imrFormatter.converter 是不是localtime 。
>
>
> > Message: 2
> > Date: Mon, 7 Jan 2008 15:50:24 +0800
> > From: "Arui Zen" <[hidden email]>
> > Subject: [python-chinese]
> >         logging模块处理时间为什么会差距个小时,有谁遇到过吗?
> >
> > To: [hidden email]
> > Cc: [hidden email]
> > Message-ID:
> >         <[hidden email]>
> > Content-Type: text/plain; charset="gb2312"
> >
> > 程序里面用了logging,默认的asctime输出的时间早了8个小时,比如现在是15:45,它输出的是05:45,我的代码:
> > 我已经显式指定了datefmt为默认格式,
> >
> > logger=logging.getLogger('IMR')
> > logger.setLevel(logging.DEBUG)
> > imrFormatter = logging.Formatter('%(asctime)s |##|
> > %(message)s',datefmt='%Y-%m-%d %H:%M:%S')
> >
> >
> > 平台:
> > ubuntu server 7.10
> > 时区: Asia/Shanghai
> >
> > 用python查看:
> > >>> import time
> > >>> time.asctime()
> > 'Mon Jan  7 15:48:34 2008'
> > >>>
> >
> > 然后程序的输出还是类似于
> > 2008-01-07 07:33:39 |##|
> > 这样的格式,整整早了8小时,
> >
> > 在另一台RHEL上运行也是一样的情况,,,,
> > 有谁遇到过类似情况吗?请指教.
> >
> > --
> >
> > DJ
>
>
> --
> THINK big, DO small.
> _______________________________________________
> python-chinese
> Post: send [hidden email]
> Subscribe: send subscribe to [hidden email]
> Unsubscribe: send unsubscribe to  [hidden email]
> Detail Info: http://python.cn/mailman/listinfo/python-chinese
_______________________________________________
python-chinese
Post: send [hidden email]
Subscribe: send subscribe to [hidden email]
Unsubscribe: send unsubscribe to  [hidden email]
Detail Info: http://python.cn/mailman/listinfo/python-chinese
Reply | Threaded
Open this post in threaded view
|

Re: logging模块处理时间为什么会差距个小时,有谁遇到过吗?

Arui Zen
In reply to this post by tairan wang
我是说在我的机器上有这个问题,上传到开发服务器上运行还是这个问题.
用date命令或者用python的time.asctime()都是正确的时间.

在08-1-7,tairan wang <[hidden email]> 写道:

1. 2台机器?
2. 如果是2台机器,Server 的时区是什么, Client 的时区又是什么?



Date: Mon, 7 Jan 2008 16:33:12 +0800
From: [hidden email]
To: [hidden email]
Subject: Re: [python-chinese] logging模块处理时间为什么会差距个小时,有谁遇到过吗?


时区 时差?

On 1/7/08, Arui Zen <[hidden email]> wrote:
程序里面用了logging,默认的asctime输出的时间早了8个小时,比如现在是15:45,它输出的是05:45,我的代码:
我已经显式指定了datefmt为默认格式,

logger=logging.getLogger ('IMR')
logger.setLevel(logging.DEBUG)
imrFormatter = logging.Formatter('%(asctime)s |##| %(message)s',datefmt='%Y-%m-%d %H:%M:%S')


平台:
ubuntu server 7.10
时区: Asia/Shanghai

用python查看:
>>> import time
>>> time.asctime()
'Mon Jan  7 15:48:34 2008'
>>>  

然后程序的输出还是类似于
2008-01-07 07:33:39 |##|
这样的格式,整整早了8小时,

在另一台RHEL上运行也是一样的情况,,,,
有谁遇到过类似情况吗?请指教.

--

DJ

_______________________________________________
python-chinese
Post: send [hidden email]
Subscribe: send subscribe to [hidden email]
Unsubscribe: send unsubscribe to  [hidden email]
Detail Info: <a href="http://python.cn/mailman/listinfo/python-chinese" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)"> http://python.cn/mailman/listinfo/python-chinese



Express yourself instantly with MSN Messenger! <a href="http://clk.atdmt.com/AVE/go/onm00200471ave/direct/01/" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">MSN Messenger

_______________________________________________
python-chinese
Post: send [hidden email]
Subscribe: send subscribe to [hidden email]
Unsubscribe: send unsubscribe to   [hidden email]
Detail Info: <a onclick="return top.js.OpenExtLink(window,event,this)" href="http://python.cn/mailman/listinfo/python-chinese" target="_blank"> http://python.cn/mailman/listinfo/python-chinese



--

DJ
_______________________________________________
python-chinese
Post: send [hidden email]
Subscribe: send subscribe to [hidden email]
Unsubscribe: send unsubscribe to  [hidden email]
Detail Info: http://python.cn/mailman/listinfo/python-chinese
Reply | Threaded
Open this post in threaded view
|

Re: logging模块处理时间为什么会差距个小时,有谁遇到过吗?

Arui Zen
In reply to this post by GoodGoodStudy&DayDayUp
这个如何查看/指定,?
fanfan19830910提示的有理!
正好8个时区,八个小时,问题是这个logging到底是从那里取的时区?好像没有设置时区的接口.

在08-1-7,GoodGoodStudy&DayDayUp <[hidden email]> 写道:
看下你的 logging.Formatter.converter  和imrFormatter.converter 是不是localtime 。


> Message: 2
> Date: Mon, 7 Jan 2008 15:50:24 +0800
> From: "Arui Zen" <[hidden email]>
> Subject: [python-chinese]
>         logging模块处理时间为什么会差距个小时,有谁遇到过吗?
>
> To: [hidden email]
> Cc: [hidden email]
> Message-ID:
>         <[hidden email]>
> Content-Type: text/plain; charset="gb2312"
>
> 程序里面用了logging,默认的asctime输出的时间早了8个小时,比如现在是15:45,它输出的是05:45,我的代码:
> 我已经显式指定了datefmt为默认格式,
>
> logger=logging.getLogger('IMR')
> logger.setLevel(logging.DEBUG)
> imrFormatter = logging.Formatter('%(asctime)s |##|
> %(message)s',datefmt='%Y-%m-%d %H:%M:%S')
>
>
> 平台:
> ubuntu server 7.10
> 时区: Asia/Shanghai
>
> 用python查看:
> >>> import time
> >>> time.asctime()
> 'Mon Jan  7 15:48:34 2008'
> >>>
>
> 然后程序的输出还是类似于
> 2008-01-07 07:33:39 |##|
> 这样的格式,整整早了8小时,
>
> 在另一台RHEL上运行也是一样的情况,,,,
> 有谁遇到过类似情况吗?请指教.
>
> --
>
> DJ


--
THINK big, DO small.
_______________________________________________
python-chinese
Post: send [hidden email]
Subscribe: send subscribe to [hidden email]
Unsubscribe: send unsubscribe to  [hidden email]
Detail Info: http://python.cn/mailman/listinfo/python-chinese



--

DJ
_______________________________________________
python-chinese
Post: send [hidden email]
Subscribe: send subscribe to [hidden email]
Unsubscribe: send unsubscribe to  [hidden email]
Detail Info: http://python.cn/mailman/listinfo/python-chinese
Reply | Threaded
Open this post in threaded view
|

Re: logging模块处理时间为什么会差距个小时,有谁遇到过吗?

luo roger
>用date命令或者用python的time.asctime()都是正确的时间
这时候,你用了终端,环境变量中设置了该用户的时区。
看看你程序运行时的环境变量。

其实程序里的时间最好都用标准时间,显示的时候再换算。

在 08-1-7,Arui Zen<[hidden email]> 写道:

> 这个如何查看/指定,?
> fanfan19830910提示的有理!
> 正好8个时区,八个小时,问题是这个logging到底是从那里取的时区?好像没有设置时区的接口.
>
> 在08-1-7,GoodGoodStudy&DayDayUp <[hidden email]> 写道:
> >
> > 看下你的 logging.Formatter.converter  和imrFormatter.converter 是不是localtime 。
> >
> >
> > > Message: 2
> > > Date: Mon, 7 Jan 2008 15:50:24 +0800
> > > From: "Arui Zen" <[hidden email]>
> > > Subject: [python-chinese]
> > >         logging模块处理时间为什么会差距个小时,有谁遇到过吗?
> > >
> > > To: [hidden email]
> > > Cc: [hidden email]
> > > Message-ID:
> > >         <[hidden email]>
> > > Content-Type: text/plain; charset="gb2312"
> > >
> > > 程序里面用了logging,默认的asctime输出的时间早了8个小时,比如现在是15:45,它输出的是05:45,我的代码:
> > > 我已经显式指定了datefmt为默认格式,
> > >
> > > logger=logging.getLogger('IMR')
> > > logger.setLevel(logging.DEBUG)
> > > imrFormatter = logging.Formatter('%(asctime)s |##|
> > > %(message)s',datefmt='%Y-%m-%d %H:%M:%S')
> > >
> > >
> > > 平台:
> > > ubuntu server 7.10
> > > 时区: Asia/Shanghai
> > >
> > > 用python查看:
> > > >>> import time
> > > >>> time.asctime()
> > > 'Mon Jan  7 15:48:34 2008'
> > > >>>
> > >
> > > 然后程序的输出还是类似于
> > > 2008-01-07 07:33:39 |##|
> > > 这样的格式,整整早了8小时,
> > >
> > > 在另一台RHEL上运行也是一样的情况,,,,
> > > 有谁遇到过类似情况吗?请指教.
> > >
> > > --
> > >
> > > DJ
> >
> >
> > --
> > THINK big, DO small.
> > _______________________________________________
> > python-chinese
> > Post: send [hidden email]
> > Subscribe: send subscribe to [hidden email]
> > Unsubscribe: send unsubscribe to  [hidden email]
> > Detail Info: http://python.cn/mailman/listinfo/python-chinese
>
>
>
>
> --
>
> DJ
>
_______________________________________________
python-chinese
Post: send [hidden email]
Subscribe: send subscribe to [hidden email]
Unsubscribe: send unsubscribe to  [hidden email]
Detail Info: http://python.cn/mailman/listinfo/python-chinese
Reply | Threaded
Open this post in threaded view
|

Re: logging模块处理时间为什么会差距个小时,有谁遇到过吗?

GoodGoodStudy&DayDayUp
In reply to this post by Arui Zen
在 Python 里面查看当然是先试着用用 print 嘛。
你 print  logging.Formatter.converter  和imrFormatter.converter 一下看看。
logging的 Formatter 在指定了 asctime 之后会调用 converter 来取得时间,一般这个converter都是
time.localtime或者 time.gmtime,如果你的 converter 是 gmtime,那么就会用
UMT时间显示,你设置的时区是上海,就是东8,这样子就会必本地时间少8。
所以说先看下这个 converter 是否已经是 localtime。

> Message: 6
> Date: Mon, 7 Jan 2008 18:19:01 +0800
> From: "Arui Zen" <[hidden email]>
> Subject: Re: [python-chinese]
>         logging模块处理时间为什么会差距个小时,有谁遇到过吗?
>
> To: [hidden email]
> Message-ID:
>         <[hidden email]>
> Content-Type: text/plain; charset="gb2312"
>
> 这个如何查看/指定,?
> fanfan19830910提示的有理!
> 正好8个时区,八个小时,问题是这个logging到底是从那里取的时区?好像没有设置时区的接口.
>
> 在08-1-7,GoodGoodStudy&DayDayUp <[hidden email]> 写道:
> >
> > 看下你的 logging.Formatter.converter  和imrFormatter.converter 是不是localtime 。
> >
> >
> > > Message: 2
> > > Date: Mon, 7 Jan 2008 15:50:24 +0800
> > > From: "Arui Zen" <[hidden email]>
> > > Subject: [python-chinese]
> > >         logging模块处理时间为什么会差距个小时,有谁遇到过吗?
> > >
> > > To: [hidden email]
> > > Cc: [hidden email]
> > > Message-ID:
> > >         <[hidden email]>
> > > Content-Type: text/plain; charset="gb2312"
> > >
> > > 程序里面用了logging,默认的asctime输出的时间早了8个小时,比如现在是15:45,它输出的是05:45,我的代码:
> > > 我已经显式指定了datefmt为默认格式,
> > >
> > > logger=logging.getLogger('IMR')
> > > logger.setLevel(logging.DEBUG)
> > > imrFormatter = logging.Formatter('%(asctime)s |##|
> > > %(message)s',datefmt='%Y-%m-%d %H:%M:%S')
> > >
> > >
> > > 平台:
> > > ubuntu server 7.10
> > > 时区: Asia/Shanghai
> > >


--
THINK big, DO small.
_______________________________________________
python-chinese
Post: send [hidden email]
Subscribe: send subscribe to [hidden email]
Unsubscribe: send unsubscribe to  [hidden email]
Detail Info: http://python.cn/mailman/listinfo/python-chinese