how to Filter the full Log context using PowerShell

陌路散爱 提交于 2020-02-01 09:46:28

问题


I am trying to filter out the logs and its full context using Select-String in powershell. I know the parameters of context and their meanings but this limits to what I am trying to achieve. Below is the log snippet and I want to search the log with date as a search parameter to select-string filter.

[AD Thread-Metric Reporter1] 16 Dec 2019 19:03:32,371 ERROR ManagedMonitorDelegate - Error sending metrics - will requeue for later transmission
com.singularity.ee.agent.commonservices.metricgeneration.metrics.MetricSendException: Connection back off limitation in effect: /controller/instance/417/metrics
    at com.singularity.ee.agent.commonservices.metricgeneration.AMetricSubscriber.publish(AMetricSubscriber.java:350)
    at com.singularity.ee.agent.commonservices.metricgeneration.MetricReporter.run(MetricReporter.java:113)
    at com.singularity.ee.util.javaspecific.scheduler.AgentScheduledExecutorServiceImpl$SafeRunnable.run(AgentScheduledExecutorServiceImpl.java:122)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    at com.singularity.ee.util.javaspecific.scheduler.ADFutureTask$Sync.innerRunAndReset(ADFutureTask.java:335)
    at com.singularity.ee.util.javaspecific.scheduler.ADFutureTask.runAndReset(ADFutureTask.java:152)
    at com.singularity.ee.util.javaspecific.scheduler.ADScheduledThreadPoolExecutor$ADScheduledFutureTask.access$101(ADScheduledThreadPoolExecutor.java:119)
    at com.singularity.ee.util.javaspecific.scheduler.ADScheduledThreadPoolExecutor$ADScheduledFutureTask.runPeriodic(ADScheduledThreadPoolExecutor.java:206)
    at com.singularity.ee.util.javaspecific.scheduler.ADScheduledThreadPoolExecutor$ADScheduledFutureTask.run(ADScheduledThreadPoolExecutor.java:236)
    at com.singularity.ee.util.javaspecific.scheduler.ADThreadPoolExecutor$Worker.runTask(ADThreadPoolExecutor.java:694)
    at com.singularity.ee.util.javaspecific.scheduler.ADThreadPoolExecutor$Worker.run(ADThreadPoolExecutor.java:726)
    at java.lang.Thread.run(Thread.java:748)
[AD Thread Pool-Global0] 16 Dec 2019 19:03:37,956 ERROR SystemAgentPollingForUpdate - Fatal transport error while connecting to URL [/controller/instance/417/systemagentpolling]: org.apache.http.conn.ConnectTimeoutException: Connect to imswt01.ecbt1.tadnet.net:8090 [imswt01.ecbt1.tadnet.net/10.228.18.71] failed: connect timed out
[AD Thread Pool-Global0] 16 Dec 2019 19:03:37,956  WARN SystemAgentPollingForUpdate - Invalid response for configuration request from controller/could not connect. Msg: Fatal transport error while connecting to URL [/controller/instance/417/systemagentpolling]
[AD Thread Pool-Global0] 16 Dec 2019 19:03:37,956  WARN SystemAgentPollingForUpdate - System configuration request failed 5 times consecutively.
[AD Thread-Metric Reporter1] 16 Dec 2019 19:03:42,362 ERROR ManagedMonitorDelegate - Error sending metrics - will requeue for later transmission
com.singularity.ee.agent.commonservices.metricgeneration.metrics.MetricSendException: Connection back off limitation in effect: /controller/instance/417/metrics
    at com.singularity.ee.agent.commonservices.metricgeneration.AMetricSubscriber.publish(AMetricSubscriber.java:350)
    at com.singularity.ee.agent.commonservices.metricgeneration.MetricReporter.run(MetricReporter.java:113)
    at com.singularity.ee.util.javaspecific.scheduler.AgentScheduledExecutorServiceImpl$SafeRunnable.run(AgentScheduledExecutorServiceImpl.java:122)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    at com.singularity.ee.util.javaspecific.scheduler.ADFutureTask$Sync.innerRunAndReset(ADFutureTask.java:335)
    at com.singularity.ee.util.javaspecific.scheduler.ADFutureTask.runAndReset(ADFutureTask.java:152)
    at com.singularity.ee.util.javaspecific.scheduler.ADScheduledThreadPoolExecutor$ADScheduledFutureTask.access$101(ADScheduledThreadPoolExecutor.java:119)
    at com.singularity.ee.util.javaspecific.scheduler.ADScheduledThreadPoolExecutor$ADScheduledFutureTask.runPeriodic(ADScheduledThreadPoolExecutor.java:206)
    at com.singularity.ee.util.javaspecific.scheduler.ADScheduledThreadPoolExecutor$ADScheduledFutureTask.run(ADScheduledThreadPoolExecutor.java:236)
    at com.singularity.ee.util.javaspecific.scheduler.ADThreadPoolExecutor$Worker.runTask(ADThreadPoolExecutor.java:694)
    at com.singularity.ee.util.javaspecific.scheduler.ADThreadPoolExecutor$Worker.run(ADThreadPoolExecutor.java:726)
    at java.lang.Thread.run(Thread.java:748)

If I run my code

Select-String "16 Dec 2019" -context 0,10

Then it filters 10 lines below the match expression. My problem is, what if the context of the log entry is bigger with many lines? Is there anyway we keep searching and printing until the new log entry is recorded? like and we get the whole Log entry context without limiting the context?

Many thanks in advance,


回答1:


Select-String can be made to work but it would be cumbersome impov. I'd use a switch statement instead implementing a simple state machine.

$inContext = $false
gc yourlog | % {
    switch -RegEx ($_) {
        "16 Dec 2019" {$inContext = $true; $_ ; continue} 
        "^\[" {$inContext = $false; continue}
        default {if ($inContext) {$_}}
    }
}

Edit cudo's to mklement0

$inContext = $false
switch -File yourlog -RegEx {
        "16 Dec 2019" {$inContext = $true; $_ ; continue} 
        "^\[" {$inContext = $false; continue}
        default {if ($inContext) {$_}}
}

Edit2 poc using provided example

$inContext = $false
@'
[AD Thread-Metric Reporter1] 16 Dec 2019 19:03:32,371 ERROR ManagedMonitorDelegate - Error sending metrics - will requeue for later transmission
com.singularity.ee.agent.commonservices.metricgeneration.metrics.MetricSendException: Connection back off limitation in effect: /controller/instance/417/metrics
    at com.singularity.ee.agent.commonservices.metricgeneration.AMetricSubscriber.publish(AMetricSubscriber.java:350)
    at com.singularity.ee.agent.commonservices.metricgeneration.MetricReporter.run(MetricReporter.java:113)
    at com.singularity.ee.util.javaspecific.scheduler.AgentScheduledExecutorServiceImpl$SafeRunnable.run(AgentScheduledExecutorServiceImpl.java:122)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    at com.singularity.ee.util.javaspecific.scheduler.ADFutureTask$Sync.innerRunAndReset(ADFutureTask.java:335)
    at com.singularity.ee.util.javaspecific.scheduler.ADFutureTask.runAndReset(ADFutureTask.java:152)
    at com.singularity.ee.util.javaspecific.scheduler.ADScheduledThreadPoolExecutor$ADScheduledFutureTask.access$101(ADScheduledThreadPoolExecutor.java:119)
    at com.singularity.ee.util.javaspecific.scheduler.ADScheduledThreadPoolExecutor$ADScheduledFutureTask.runPeriodic(ADScheduledThreadPoolExecutor.java:206)
    at com.singularity.ee.util.javaspecific.scheduler.ADScheduledThreadPoolExecutor$ADScheduledFutureTask.run(ADScheduledThreadPoolExecutor.java:236)
    at com.singularity.ee.util.javaspecific.scheduler.ADThreadPoolExecutor$Worker.runTask(ADThreadPoolExecutor.java:694)
    at com.singularity.ee.util.javaspecific.scheduler.ADThreadPoolExecutor$Worker.run(ADThreadPoolExecutor.java:726)
    at java.lang.Thread.run(Thread.java:748)
[AD Thread Pool-Global0] 16 Dec 2019 19:03:37,956 ERROR SystemAgentPollingForUpdate - Fatal transport error while connecting to URL [/controller/instance/417/systemagentpolling]: org.apache.http.conn.ConnectTimeoutException: Connect to imswt01.ecbt1.tadnet.net:8090 [imswt01.ecbt1.tadnet.net/10.228.18.71] failed: connect timed out
[AD Thread Pool-Global0] 16 Dec 2019 19:03:37,956  WARN SystemAgentPollingForUpdate - Invalid response for configuration request from controller/could not connect. Msg: Fatal transport error while connecting to URL [/controller/instance/417/systemagentpolling]
[AD Thread Pool-Global0] 16 Dec 2019 19:03:37,956  WARN SystemAgentPollingForUpdate - System configuration request failed 5 times consecutively.
[AD Thread-Metric Reporter1] 16 Dec 2019 19:03:42,362 ERROR ManagedMonitorDelegate - Error sending metrics - will requeue for later transmission
com.singularity.ee.agent.commonservices.metricgeneration.metrics.MetricSendException: Connection back off limitation in effect: /controller/instance/417/metrics
    at com.singularity.ee.agent.commonservices.metricgeneration.AMetricSubscriber.publish(AMetricSubscriber.java:350)
    at com.singularity.ee.agent.commonservices.metricgeneration.MetricReporter.run(MetricReporter.java:113)
    at com.singularity.ee.util.javaspecific.scheduler.AgentScheduledExecutorServiceImpl$SafeRunnable.run(AgentScheduledExecutorServiceImpl.java:122)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    at com.singularity.ee.util.javaspecific.scheduler.ADFutureTask$Sync.innerRunAndReset(ADFutureTask.java:335)
    at com.singularity.ee.util.javaspecific.scheduler.ADFutureTask.runAndReset(ADFutureTask.java:152)
    at com.singularity.ee.util.javaspecific.scheduler.ADScheduledThreadPoolExecutor$ADScheduledFutureTask.access$101(ADScheduledThreadPoolExecutor.java:119)
    at com.singularity.ee.util.javaspecific.scheduler.ADScheduledThreadPoolExecutor$ADScheduledFutureTask.runPeriodic(ADScheduledThreadPoolExecutor.java:206)
    at com.singularity.ee.util.javaspecific.scheduler.ADScheduledThreadPoolExecutor$ADScheduledFutureTask.run(ADScheduledThreadPoolExecutor.java:236)
    at com.singularity.ee.util.javaspecific.scheduler.ADThreadPoolExecutor$Worker.runTask(ADThreadPoolExecutor.java:694)
    at com.singularity.ee.util.javaspecific.scheduler.ADThreadPoolExecutor$Worker.run(ADThreadPoolExecutor.java:726)
    at java.lang.Thread.run(Thread.java:748)
[AD Thread-Metric Reporter1] 16 Dec 2019 19:03:52,369 ERROR ManagedMonitorDelegate - Error sending metrics - will requeue for later transmission
com.singularity.ee.agent.commonservices.metricgeneration.metrics.MetricSendException: Connection back off limitation in effect: /controller/instance/417/metrics
    at com.singularity.ee.agent.commonservices.metricgeneration.AMetricSubscriber.publish(AMetricSubscriber.java:350)
    at com.singularity.ee.agent.commonservices.metricgeneration.MetricReporter.run(MetricReporter.java:113)
    at com.singularity.ee.util.javaspecific.scheduler.AgentScheduledExecutorServiceImpl$SafeRunnable.run(AgentScheduledExecutorServiceImpl.java:122)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    at com.singularity.ee.util.javaspecific.scheduler.ADFutureTask$Sync.innerRunAndReset(ADFutureTask.java:335)
    at com.singularity.ee.util.javaspecific.scheduler.ADFutureTask.runAndReset(ADFutureTask.java:152)
    at com.singularity.ee.util.javaspecific.scheduler.ADScheduledThreadPoolExecutor$ADScheduledFutureTask.access$101(ADScheduledThreadPoolExecutor.java:119)
    at com.singularity.ee.util.javaspecific.scheduler.ADScheduledThreadPoolExecutor$ADScheduledFutureTask.runPeriodic(ADScheduledThreadPoolExecutor.java:206)
    at com.singularity.ee.util.javaspecific.scheduler.ADScheduledThreadPoolExecutor$ADScheduledFutureTask.run(ADScheduledThreadPoolExecutor.java:236)
    at com.singularity.ee.util.javaspecific.scheduler.ADThreadPoolExecutor$Worker.runTask(ADThreadPoolExecutor.java:694)
    at com.singularity.ee.util.javaspecific.scheduler.ADThreadPoolExecutor$Worker.run(ADThreadPoolExecutor.java:726)
    at java.lang.Thread.run(Thread.java:748)
[extension-scheduler-pool-1] 16 Dec 2019 19:03:55,283  WARN ProcessMonitor - ProcessMonitor::Caught exception during collection and reporting.
feign.RetryableException: Connect to imswt01.ecbt1.tadnet.net:8090 [imswt01.ecbt1.tadnet.net/10.228.18.71] failed: Connection refused: connect executing PUT http://imswt01.ecbt1.tadnet.net:8090/controller/sim/v2/agent/machines/imswd97/processes
    at feign.FeignException.errorExecuting(FeignException.java:67)
    at feign.SynchronousMethodHandler.executeAndDecode(SynchronousMethodHandler.java:102)
    at feign.SynchronousMethodHandler.invoke(SynchronousMethodHandler.java:76)
    at feign.ReflectiveFeign$FeignInvocationHandler.invoke(ReflectiveFeign.java:103)
    at com.sun.proxy.$Proxy126.updateProcessMetadata(Unknown Source)
    at com.appdynamics.sim.agent.extensions.servers.DoubleBufferedProcessProperties.reportProcesses(DoubleBufferedProcessProperties.java:75)
    at com.appdynamics.sim.agent.extensions.servers.ProcessMonitor.run(ProcessMonitor.java:78)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:308)
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:180)
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:294)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    at java.lang.Thread.run(Thread.java:748)
Caused by: org.apache.http.conn.HttpHostConnectException: Connect to imswt01.ecbt1.tadnet.net:8090 [imswt01.ecbt1.tadnet.net/10.228.18.71] failed: Connection refused: connect
    at org.apache.http.impl.conn.DefaultHttpClientConnectionOperator.connect(DefaultHttpClientConnectionOperator.java:159)
    at org.apache.http.impl.conn.PoolingHttpClientConnectionManager.connect(PoolingHttpClientConnectionManager.java:373)
    at org.apache.http.impl.execchain.MainClientExec.establishRoute(MainClientExec.java:381)
    at org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:237)
    at org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:185)
    at org.apache.http.impl.execchain.RetryExec.execute(RetryExec.java:89)
    at org.apache.http.impl.execchain.RedirectExec.execute(RedirectExec.java:111)
    at org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:185)
    at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:72)
    at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:221)
    at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:165)
    at com.appdynamics.voltron.rest.client.impl.apache.ManagedHttpClient.execute(ManagedHttpClient.java:83)
    at com.appdynamics.voltron.rest.client.impl.apache.ApacheClientImpl.execute(ApacheClientImpl.java:77)
    at feign.SynchronousMethodHandler.executeAndDecode(SynchronousMethodHandler.java:97)
    ... 12 more
Caused by: java.net.ConnectException: Connection refused: connect
    at java.net.DualStackPlainSocketImpl.waitForConnect(Native Method)
    at java.net.DualStackPlainSocketImpl.socketConnect(DualStackPlainSocketImpl.java:85)
    at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350)
    at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)
    at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)
    at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:172)
    at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
    at java.net.Socket.connect(Socket.java:589)
    at org.apache.http.conn.socket.PlainConnectionSocketFactory.connectSocket(PlainConnectionSocketFactory.java:75)
    at org.apache.http.impl.conn.DefaultHttpClientConnectionOperator.connect(DefaultHttpClientConnectionOperator.java:142)
    ... 25 more
[system-thread-0] 16 Dec 2019 19:03:55,643  WARN RegistrationTask - Encountered error during registration. Will retry in 60 seconds.
[AD Thread-Metric Reporter0] 16 Dec 2019 19:04:00,003  WARN ManagedMonitorDelegate - Metric Reporter Queue full. Dropping metrics.
[system-thread-0] 16 Dec 2019 19:04:02,013  WARN DynamicMonitoringModeTask - Encountered error checking monitoring mode. Will retry in 60 seconds.
[AD Thread-Metric Reporter1] 16 Dec 2019 19:04:02,357 ERROR ManagedMonitorDelegate - Error sending metrics - will requeue for later transmission
com.singularity.ee.agent.commonservices.metricgeneration.metrics.MetricSendException: Connection back off limitation in effect: /controller/instance/417/metrics
    at com.singularity.ee.agent.commonservices.metricgeneration.AMetricSubscriber.publish(AMetricSubscriber.java:350)
    at com.singularity.ee.agent.commonservices.metricgeneration.MetricReporter.run(MetricReporter.java:113)
    at com.singularity.ee.util.javaspecific.scheduler.AgentScheduledExecutorServiceImpl$SafeRunnable.run(AgentScheduledExecutorServiceImpl.java:122)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    at com.singularity.ee.util.javaspecific.scheduler.ADFutureTask$Sync.innerRunAndReset(ADFutureTask.java:335)
    at com.singularity.ee.util.javaspecific.scheduler.ADFutureTask.runAndReset(ADFutureTask.java:152)
    at com.singularity.ee.util.javaspecific.scheduler.ADScheduledThreadPoolExecutor$ADScheduledFutureTask.access$101(ADScheduledThreadPoolExecutor.java:119)
    at com.singularity.ee.util.javaspecific.scheduler.ADScheduledThreadPoolExecutor$ADScheduledFutureTask.runPeriodic(ADScheduledThreadPoolExecutor.java:206)
    at com.singularity.ee.util.javaspecific.scheduler.ADScheduledThreadPoolExecutor$ADScheduledFutureTask.run(ADScheduledThreadPoolExecutor.java:236)
    at com.singularity.ee.util.javaspecific.scheduler.ADThreadPoolExecutor$Worker.runTask(ADThreadPoolExecutor.java:694)
    at com.singularity.ee.util.javaspecific.scheduler.ADThreadPoolExecutor$Worker.run(ADThreadPoolExecutor.java:726)
    at java.lang.Thread.run(Thread.java:748)
[system-thread-0] 16 Dec 2019 19:04:08,387  WARN RegistrationTask - Encountered error during registration. Will retry in 60 seconds.
[AD Thread-Metric Reporter1] 16 Dec 2019 19:04:12,358 ERROR ManagedMonitorDelegate - Error sending metrics - will requeue for later transmission
com.singularity.ee.agent.commonservices.metricgeneration.metrics.MetricSendException: Connection back off limitation in effect: /controller/instance/417/metrics
    at com.singularity.ee.agent.commonservices.metricgeneration.AMetricSubscriber.publish(AMetricSubscriber.java:350)
    at com.singularity.ee.agent.commonservices.metricgeneration.MetricReporter.run(MetricReporter.java:113)
    at com.singularity.ee.util.javaspecific.scheduler.AgentScheduledExecutorServiceImpl$SafeRunnable.run(AgentScheduledExecutorServiceImpl.java:122)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    at com.singularity.ee.util.javaspecific.scheduler.ADFutureTask$Sync.innerRunAndReset(ADFutureTask.java:335)
    at com.singularity.ee.util.javaspecific.scheduler.ADFutureTask.runAndReset(ADFutureTask.java:152)
    at com.singularity.ee.util.javaspecific.scheduler.ADScheduledThreadPoolExecutor$ADScheduledFutureTask.access$101(ADScheduledThreadPoolExecutor.java:119)
    at com.singularity.ee.util.javaspecific.scheduler.ADScheduledThreadPoolExecutor$ADScheduledFutureTask.runPeriodic(ADScheduledThreadPoolExecutor.java:206)
    at com.singularity.ee.util.javaspecific.scheduler.ADScheduledThreadPoolExecutor$ADScheduledFutureTask.run(ADScheduledThreadPoolExecutor.java:236)
    at com.singularity.ee.util.javaspecific.scheduler.ADThreadPoolExecutor$Worker.runTask(ADThreadPoolExecutor.java:694)
    at com.singularity.ee.util.javaspecific.scheduler.ADThreadPoolExecutor$Worker.run(ADThreadPoolExecutor.java:726)
    at java.lang.Thread.run(Thread.java:748)
[Agent-Scheduler-1] 16 Dec 2019 19:04:23,615 ERROR ControllerTimeSkewHandler - Error response from controller: Connection back off limitation in effect: /controller/instance/417/current-time
[AD Thread-Metric Reporter1] 16 Dec 2019 19:04:27,365 ERROR ManagedMonitorDelegate - Fatal transport error while connecting to URL [/controller/instance/417/metrics]: org.apache.http.conn.ConnectTimeoutException: Connect to imswt01.ecbt1.tadnet.net:8090 [imswt01.ecbt1.tadnet.net/10.228.18.71] failed: connect timed out
[AD Thread-Metric Reporter1] 16 Dec 2019 19:04:27,365  WARN ManagedMonitorDelegate - Error sending metric data to controller:Fatal transport error while connecting to URL [/controller/instance/417/metrics]
[AD Thread-Metric Reporter1] 16 Dec 2019 19:04:27,365 ERROR ManagedMonitorDelegate - Error sending metrics - will requeue for later transmission
com.singularity.ee.agent.commonservices.metricgeneration.metrics.MetricSendException: Fatal transport error while connecting to URL [/controller/instance/417/metrics]
    at com.singularity.ee.agent.commonservices.metricgeneration.AMetricSubscriber.publish(AMetricSubscriber.java:350)
    at com.singularity.ee.agent.commonservices.metricgeneration.MetricReporter.run(MetricReporter.java:113)
    at com.singularity.ee.util.javaspecific.scheduler.AgentScheduledExecutorServiceImpl$SafeRunnable.run(AgentScheduledExecutorServiceImpl.java:122)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    at com.singularity.ee.util.javaspecific.scheduler.ADFutureTask$Sync.innerRunAndReset(ADFutureTask.java:335)
    at com.singularity.ee.util.javaspecific.scheduler.ADFutureTask.runAndReset(ADFutureTask.java:152)
    at com.singularity.ee.util.javaspecific.scheduler.ADScheduledThreadPoolExecutor$ADScheduledFutureTask.access$101(ADScheduledThreadPoolExecutor.java:119)
    at com.singularity.ee.util.javaspecific.scheduler.ADScheduledThreadPoolExecutor$ADScheduledFutureTask.runPeriodic(ADScheduledThreadPoolExecutor.java:206)
    at com.singularity.ee.util.javaspecific.scheduler.ADScheduledThreadPoolExecutor$ADScheduledFutureTask.run(ADScheduledThreadPoolExecutor.java:236)
    at com.singularity.ee.util.javaspecific.scheduler.ADThreadPoolExecutor$Worker.runTask(ADThreadPoolExecutor.java:694)
    at com.singularity.ee.util.javaspecific.scheduler.ADThreadPoolExecutor$Worker.run(ADThreadPoolExecutor.java:726)
    at java.lang.Thread.run(Thread.java:748)
  [system-thread-0] 16 Dec 2019 19:05:54,030  WARN DynamicMonitoringModeTask - Encountered error checking monitoring mode. Will retry in 60 seconds.
[system-thread-0] 16 Dec 2019 19:05:54,030  WARN RegistrationTask - Encountered error during registration. Will retry in 60 seconds.
[system-thread-0] 16 Dec 2019 19:05:54,030  WARN DynamicMonitoringModeTask - Encountered error checking monitoring mode. Will retry in 60 seconds.
[system-thread-0] 16 Dec 2019 19:05:54,030  WARN RegistrationTask - Encountered error during registration. Will retry in 60 seconds.
[system-thread-0] 16 Dec 2019 19:05:54,030  WARN DynamicMonitoringModeTask - Encountered error checking monitoring mode. Will retry in 60 seconds.
[system-thread-0] 16 Dec 2019 19:05:54,046  WARN RegistrationTask - Encountered error during registration. Will retry in 60 seconds.
[system-thread-0] 16 Dec 2019 19:05:54,046  WARN DynamicMonitoringModeTask - Encountered error checking monitoring mode. Will retry in 60 seconds.
[system-thread-0] 16 Dec 2019 19:05:54,046  WARN RegistrationTask - Encountered error during registration. Will retry in 60 seconds.
[system-thread-0] 16 Dec 2019 19:05:54,046  WARN DynamicMonitoringModeTask - Encountered error checking monitoring mode. Will retry in 60 seconds.
[system-thread-0] 16 Dec 2019 19:05:54,046  WARN RegistrationTask - Encountered error during registration. Will retry in 60 seconds.
[extension-scheduler-pool-6] 18 Dec 2019 19:31:36,365  INFO ReportMetricsConfigSupplier - Basic metrics will be collected and reported through the SIM extension because SIM is enabled.
[extension-scheduler-pool-3] 18 Dec 2019 19:36:36,369  INFO ReportMetricsConfigSupplier - Basic metrics will be collected and reported through the SIM extension because SIM is enabled.
[extension-scheduler-pool-9] 18 Dec 2019 19:41:36,374  INFO ReportMetricsConfigSupplier - Basic metrics will be collected and reported through the SIM extension because SIM is enabled.
[extension-scheduler-pool-11] 18 Dec 2019 19:46:36,378  INFO ReportMetricsConfigSupplier - Basic metrics will be collected and reported through the SIM extension because SIM is enabled.
[extension-scheduler-pool-1] 18 Dec 2019 19:51:36,382  INFO ReportMetricsConfigSupplier - Basic metrics will be collected and reported through the SIM extension because SIM is enabled.
[extension-scheduler-pool-7] 18 Dec 2019 19:56:36,387  INFO ReportMetricsConfigSupplier - Basic metrics will be collected and reported through the SIM extension because SIM is enabled.
[extension-scheduler-pool-8] 18 Dec 2019 20:01:36,391  INFO ReportMetricsConfigSupplier - Basic metrics will be collected and reported through the SIM extension because SIM is enabled.
[extension-scheduler-pool-7] 18 Dec 2019 20:06:36,396  INFO ReportMetricsConfigSupplier - Basic metrics will be collected and reported through the SIM extension because SIM is enabled.
[extension-scheduler-pool-9] 18 Dec 2019 20:11:36,400  INFO ReportMetricsConfigSupplier - Basic metrics will be collected and reported through the SIM extension because SIM is enabled.
[extension-scheduler-pool-6] 18 Dec 2019 20:16:36,405  INFO ReportMetricsConfigSupplier - Basic metrics will be collected and reported through the SIM extension because SIM is enabled.
[extension-scheduler-pool-4] 18 Dec 2019 20:21:36,409  INFO ReportMetricsConfigSupplier - 
'@ -split "`r`n" | % {
    switch -RegEx ($_) {
        "16 Dec 2019" { $inContext = $true; $_ ; continue} 
        "^\["{ $inContext = $false; continue}
        default { if ($inContext) {$_}}
    }
}


来源:https://stackoverflow.com/questions/59716965/how-to-filter-the-full-log-context-using-powershell

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!