VMware Cloud Community
nava_thulasi39

How to extract the logs in the particular time range?

Hi,

I am not sure, this type of query already answered here.

I am trying to extract the log file in the time range (ex: between 9 - 9.30).

I am using the powercli to filter errors in the logs like

$log = get-log -key xxxx -server <hostname>

$log.entries | select-string "Error"

But I would like to know the logs within the time range. As well as if anybody helps to use startlinenum & lastlinenum - it will be useful.

Thanks in advance.

If you find this or any other answer useful please consider awarding points by marking the answer correct or helpful
0 Kudos
5 Replies
FranckRookie
Leadership
Leadership

Hi Nava,

You can try using the "Get-VIEvent" cmdlet with Start and Finish parameters. Have a look here:

Good luck.

Regards

Franck

0 Kudos
nava_thulasi39

Thanks Franck.

So can't we use startlinenum & lastlinenum in the get-log cmdlet.

There is a parameter in the get-log

[vSphere PowerCLI] C:\Powercli> get-log -key xxxxxx | gm
   TypeName: VMware.VimAutomation.Client20.LogImpl
Name           MemberType Definition
----           ---------- ----------
Equals         Method     bool Equals(System.Object obj)
GetHashCode    Method     int GetHashCode()
GetType        Method     type GetType()
ToString       Method     string ToString()
Entries        Property   System.String[] Entries {get;}
Host           Property   VMware.VimAutomation.Types.VMHost Host {get;}
Key            Property   System.String Key {get;}
LastLineNum    Property   System.Int32 LastLineNum {get;}
Server         Property   VMware.VimAutomation.Types.VIServer Server {get;}
SourceEntityId Property   System.String SourceEntityId {get;}
StartLineNum   Property   System.Int32 StartLineNum {get;}
Again, I am newbie in the powercli. So trying how to use this parameter.
If you find this or any other answer useful please consider awarding points by marking the answer correct or helpful
0 Kudos
DSTAVERT
Immortal
Immortal

Also remember that ESXi uses UTC exclusively.

-- David -- VMware Communities Moderator
LucD
Leadership
Leadership

Yes, you can use the StartLineNum parameter on the Get-Log cmdlet.

There is no LastLineNum parameter but you can use the NumLines parameter combined with StartLineNum to achieve a similar result.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

nava_thulasi39

Yes. Almost I got the answer.

If you find this or any other answer useful please consider awarding points by marking the answer correct or helpful
0 Kudos