File tree Expand file tree Collapse file tree 1 file changed +34
-0
lines changed
cf-java-logging-support-servlet/src/main/java/com/sap/hcp/cf/logging/servlet/filter Expand file tree Collapse file tree 1 file changed +34
-0
lines changed Original file line number Diff line number Diff line change 1+ package com .sap .hcp .cf .logging .servlet .filter ;
2+
3+ import javax .servlet .http .HttpServletRequest ;
4+ import javax .servlet .http .HttpServletResponse ;
5+
6+ import com .sap .hcp .cf .logging .common .LogContext ;
7+
8+ /**
9+ * <p>
10+ * The {@link AddVcapEnvironmentToLogContextFilter} extracts CF specific
11+ * metadata about the running application and adds it to the log context. The
12+ * metadata includes the app, org and space names and ids. This allows to
13+ * attribute a generated log message to the correct source from the message
14+ * alone.
15+ * </p>
16+ *
17+ * <p>
18+ * <b>Note:</b> This metadata can usually also be obtained from the CF channel
19+ * shipping the logs, e.g. syslog structured data. Hence, depending on the
20+ * use-case, it may not be required to add the metadata with this filter.
21+ * </p>
22+ */
23+ public class AddVcapEnvironmentToLogContextFilter extends AbstractLoggingFilter {
24+
25+ @ Override
26+ protected void preProcess (HttpServletRequest request , HttpServletResponse response ) {
27+ LogContext .loadContextFields ();
28+ }
29+
30+ @ Override
31+ protected void postProcess (HttpServletRequest request , HttpServletResponse response ) {
32+ LogContext .resetContextFields ();
33+ }
34+ }
You can’t perform that action at this time.
0 commit comments