Apache Log4cxx  Version 2.0.0
Loading...
Searching...
No Matches
ecslayout.h
Go to the documentation of this file.
1/*
2 * Licensed to the Apache Software Foundation (ASF) under one or more
3 * contributor license agreements. See the NOTICE file distributed with
4 * this work for additional information regarding copyright ownership.
5 * The ASF licenses this file to You under the Apache License, Version 2.0
6 * (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17
18#ifndef _LOG4CXX_ECS_LAYOUT_H
19#define _LOG4CXX_ECS_LAYOUT_H
20
21#include <log4cxx/layout.h>
22
23
24namespace LOG4CXX_NS
25{
86class LOG4CXX_EXPORT ECSLayout : public Layout
87{
88 private:
89 LOG4CXX_DECLARE_PRIVATE_MEMBER_PTR(ECSLayoutPrivate, m_priv)
90
91 public:
97
99
101
106 void setServiceName(const LogString& newValue);
107
111 const LogString& getServiceName() const;
112
117 void setServiceVersion(const LogString& newValue);
118
123
129 void setServiceEnvironment(const LogString& newValue);
130
135
141 void setServiceNodeName(const LogString& newValue);
142
147
152 void setEventDataset(const LogString& newValue);
153
159
165 void setLocationInfo(bool newValue);
166
170 bool getLocationInfo() const;
171
175 LogString getContentType() const override;
176
177 using Layout::activateOptions;
183 bool activateOptions() override;
184
200 void setOption(const LogString& option, const LogString& value) override;
201
202 using Layout::format;
206 void format(LogString& output, const spi::LoggingEventPtr& event) const override;
207
212 bool ignoresThrowable() const override
213 {
214 return false;
215 }
216
217}; // class ECSLayout
218
220} // namespace log4cxx
221
222#endif // _LOG4CXX_ECS_LAYOUT_H
This layout outputs each event as a single line JSON object using the field names of the Elastic Comm...
Definition ecslayout.h:87
bool activateOptions() override
Activate the options that were previously set with calls to option setters.
const LogString & getServiceName() const
The service.name field value.
void setServiceName(const LogString &newValue)
Use newValue as the service.name field value.
LogString getContentType() const override
Returns the content type output by this layout, i.e "application/json".
bool ignoresThrowable() const override
The ECS layout handles the throwable contained in logging events.
Definition ecslayout.h:212
const LogString & getServiceVersion() const
The service.version field value.
const LogString & getServiceEnvironment() const
The service.environment field value.
void format(LogString &output, const spi::LoggingEventPtr &event) const override
Append the attributes of event as a single line JSON object onto output.
void setLocationInfo(bool newValue)
Include the source code location (the log.origin.
const LogString & getServiceNodeName() const
The service.node.name field value.
void setServiceEnvironment(const LogString &newValue)
Use newValue as the service.environment field value, e.g.
const LogString & getEventDataset() const
The event.dataset field value (the ServiceName option value when EventDataset is empty).
void setServiceNodeName(const LogString &newValue)
Use newValue as the service.node.name field value, which identifies a particular instance of a servic...
bool getLocationInfo() const
Is the source code location of the logging request included?
void setServiceVersion(const LogString &newValue)
Use newValue as the service.version field value.
void setEventDataset(const LogString &newValue)
Use newValue as the event.dataset field value.
void setOption(const LogString &option, const LogString &value) override
Override this method to set option to value.
Extend this abstract class to create your own log layout format.
Definition layout.h:33
Definition appender.h:30
std::basic_string< logchar > LogString
Definition logstring.h:51
LOG4CXX_PTR_DEF(Appender)
#define LOG4CXX_CAST_ENTRY(Interface)
Definition object.h:153
#define END_LOG4CXX_CAST_MAP()
Definition object.h:147
#define DECLARE_LOG4CXX_OBJECT(object)
Definition object.h:41
#define LOG4CXX_CAST_ENTRY_CHAIN(Interface)
Definition object.h:159
#define BEGIN_LOG4CXX_CAST_MAP()
Definition object.h:141