# Log Error Detection Settings

An application log file records various events, errors, and information generated during the execution of an application. The yc-360 script monitors these logs for critical errors. When such errors are detected, the yc-360 script automatically captures 360° troubleshooting artifacts, including GC logs, thread dumps, top, netstat, vmstat, dmesg, and more, then sends them to the yCrash server for analysis.

You can configure yCrash to perform this 360° capture only when specific sensitive errors appear in your application logs. In this post, we'll discuss how to set up this configuration.

# Create 'log-error-settings.json'

  1. Download log-error-settings.json file from this location (opens new window).

  2. Place this log-error-settings.json file in the yCrash Server’s upload directory. If you're using remote storage, store the file in the root directory of your remote storage ((e.g.,AWS S3, Google Cloud Storage).

The yCrash application will first check for the file locally. If it's found, it will be read from the local directory. If not, it will search for the file in the remote storage.

# Configure 'log-error-settings.json'

For example, consider the following exception that is reported in your application log file:

2024-01-23 12:55:09,539; INFO; c.t.f.a.PayloadReaderOne; ; 12982400B5B5B8B8E25C1D0657F70FFA; 003aa871-a537-4527-b9e8-39e04ee78f93; http-nio-8080-exec-6; Failed to get file name from parts - java.lang.IllegalStateException: Unable to process parts as no multi-part configuration has been provided
	at org.apache.catalina.connector.Request.parseParts(Request.java:2866)
	at org.apache.catalina.connector.Request.getParts(Request.java:2834)
	at org.apache.catalina.connector.RequestFacade.getParts(RequestFacade.java:1098)
	at buggyapp.PayloadReaderOne.getFileNameFromPart(PayloadReaderOne.java:636)
1
2
3
4
5

If you want to trigger a 360° capture whenever a java.lang.IllegalStateException appears in the application log, you can configure the log-error-settings.json file as shown below.

{
    "capture360Data": {
        "globalSettings": [
            {
                "matchPatterns": [
                    "java.lang.IllegalStateException"
                ]
            }
        ]
    }
}
1
2
3
4
5
6
7
8
9
10
11

If you also want to trigger a 360° capture for both java.lang.OutOfMemoryError and java.lang.IllegalStateException, your configuration would look like this:

{
    "capture360Data": {
        "globalSettings": [
            {
                "matchPatterns": [
                    "java.lang.OutofMemoryError"
                ]
            },
            {
                "matchPatterns": [
                    "java.lang.IllegalStateException"
                ]
            }
        ]
    }
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16

# Configure YAML file

Below is an example of how to configure the YAML file. Make sure to place the application log path correctly and maintain the alignment properly in the YAML file.

version: '1'
options:
k: [API Key]                    
s: http://localhost:8080
   appLogs: 
   - D:\tier1app\t-log\dashboard\logs\ycrash.log$FinanceApp
   processTokens:
   - 9016$FinanceApp
1
2
3
4
5
6
7
8

# Advanced Settings

Let’s explore some of the advanced settings that you can leverage.

# 1. Error Frequency

In some situations, you may need to capture 360° troubleshooting data only when an error occurs multiple times within a specific time frame. For example, if you want to capture troubleshooting artifacts when a java.lang.IllegalStateException occurs 3 times within a 5-minute window, the configuration should be as follows:






 

 
 





{
    "capture360Data": {
      "globalSettings": [
        {
            "matchPatterns": [
              "java.lang.IllegalStateException"
            ],
           "timeWindow":"5min",
           "count":"3"
          }
    ]
   }
}
1
2
3
4
5
6
7
8
9
10
11
12
13

Note: The timeWindow parameter can be configured using min (minutes) or hr (hours).

# 2. Match Criteria

For more precise log line pattern matching, you can configure four types of matching criteria.

a. REGEX








 







{
    "capture360Data": {
      "globalSettings": [
          {
            "matchPatterns": [
              ".*OutofMemoryError"
            ],
            "matchCriteria": "REGEX",
            "timeWindow":"3min",
            "count":"5"
          }
      ]
    }
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14

If you want to trigger a 360° capture whenever any exception from the java.lang package occurs, you can use regular expression matching criteria, as demonstrated above.

b. WHOLE_WORD








 







{
    "capture360Data": {
      "globalSettings": [
          {
            "matchPatterns": [
              "OutofMemoryError"
            ],
            "matchCriteria": "WHOLE_WORD",
            "timeWindow":"3min",
            "count":"5"
          }
      ]
    }
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14

If you want to match log messages on a whole-word basis, you can configure it as shown above.

c. CASE_SENSITIVE








 







{
    "capture360Data": {
      "globalSettings": [
          {
            "matchPatterns": [
              "OutofMemoryError"
            ],
            "matchCriteria": "CASE_SENSITIVE",
            "timeWindow":"3min",
            "count":"5"
          }
      ]
    }
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14

If you want to match log messages in a case-sensitive manner, you can configure it as shown above.

d. NONE








 







{
    "capture360Data": {
      "globalSettings": [
          {
            "matchPatterns": [
              "OutofMemoryError"
            ],
            "matchCriteria": "NONE",
            "timeWindow":"3min",
            "count":"5"
          }
      ]
    }
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14

This is the default option, meaning no additional criteria are applied beyond the presence of the specified pattern. It essentially matches any log entry that contains the pattern without further conditions.

Note:

If no match criteria are explicitly set, the default is considered as "NONE".

# 3. Matching Multi-Log Lines

{
  "capture360Data": {
    "globalSettings": [
      {
        "matchPatterns": [
          "at org.apache.catalina.connector.Request.parseParts(Request.java:2866)",
          "at org.apache.catalina.connector.Request.getParts(Request.java:2834)",
          "at org.apache.catalina.connector.RequestFacade.getParts(RequestFacade.java:1098)",
          "at buggyapp.PayloadReaderOne.getFileNameFromPart(PayloadReaderOne.java:636)"
        ]
      }
    ]
  }
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14

If you want to match multiple log lines, you can configure it as shown above.

# 4. Application Level Settings

When monitoring multiple applications with yCrash, you may want to configure log error settings selectively for each application.

# 4.1 Configuration in JSON File:

Use the appSettings array element in the log-error-settings.json file, as shown below:

{
	"capture360Data": {
	  "globalSettings": [
		{
			"matchPatterns": [
			  "java.lang.IllegalStateException"
			],
		   "timeWindow":"5min",
		   "count":"3"
		  }
	  ],
	  "appSettings": [
		{
		  "appName": "FinanceApp",
		  "logRules": [
			{
			  "matchPatterns": [
				".*Memory Leak"
			  ],
			  "matchCriteria": "REGEX"
			}
		  ]
		}
	  ]
	}
  }
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26

In the JSON example above, the appSettings section contains an object with "appName": "FinanceApp", which specifies that the application's name is FinanceApp.

# 4.2 Configuration in YAML file:

The condition you want to enforce is that the value following the $ symbol in processTokens must match the corresponding appName in the JSON file. In this case, both the yaml and JSON file are provided with the same app name as "FinanceApp", so they meet the specified condition.

# 4.2.1 YAML File Configuration while monitoring single application

version: '1'
options:
k: [API Key]
s: http://localhost:8080
appLogs: 
- D:\tier1app\t-log\dashboard\logs\ycrash.log$FinanceApp
processTokens:
- 9016$FinanceApp
1
2
3
4
5
6
7
8

If you are monitoring multiple applications, ensure that the values following the $symbol in processTokens match the corresponding appName in the JSON file's appSettings. Adjust these values as necessary to maintain consistency and meet your specific requirements.

Make sure to review and adjust the values as needed to ensure correct matching between the YAML and JSON configurations.

Note:

Make sure to restart the server each time after making any change in both the YAML and JSON file.

# 5. Escaping Special Characters

If you want to add special characters, such as Carriage return \r, Tab \t, Double quote ", Backslash \.. they need to be escaped properly. Learn about it from here.