/* * Copyright 2003,2004 The Apache Software Foundation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef _LOG4CXX_XML_LAYOUT_H #define _LOG4CXX_XML_LAYOUT_H #include namespace log4cxx { namespace xml { class XMLLayout; typedef helpers::ObjectPtrT XMLLayoutPtr; /** The output of the XMLLayout consists of a series of log4j:event elements as defined in the log4j.dtd. It does not output a complete well-formed XML file. The output is designed to be included as an external entity in a separate file to form a correct XML file.

For example, if abc is the name of the file where the XMLLayout ouput goes, then a well-formed XML file would be: ]> @&data;

This approach enforces the independence of the XMLLayout and the appender where it is embedded. */ class LOG4CXX_EXPORT XMLLayout : public Layout { private: /** A string constant used in naming the option for setting the the location information flag. Current value of this string constant is LocationInfo. */ static String LOCATION_INFO_OPTION; // Print no location info by default bool locationInfo; //= false public: DECLARE_LOG4CXX_OBJECT(XMLLayout) BEGIN_LOG4CXX_CAST_MAP() LOG4CXX_CAST_ENTRY(XMLLayout) LOG4CXX_CAST_ENTRY_CHAIN(Layout) END_LOG4CXX_CAST_MAP() XMLLayout(); /** The LocationInfo option takes a boolean value. By default, it is set to false which means there will be no location information output by this layout. If the the option is set to true, then the file name and line number of the statement at the origin of the log statement will be output.

If you are embedding this layout within a SMTPAppender then make sure to set the LocationInfo option of that appender as well. */ inline void setLocationInfo(bool locationInfo) { this->locationInfo = locationInfo; } /** Returns the current value of the LocationInfo option. */ inline bool getLocationInfo() const { return locationInfo; } /** No options to activate. */ void activateOptions() { } /** Set options */ virtual void setOption(const String& option, const String& value); /** * Formats a {@link spi::LoggingEvent LoggingEvent} * in conformance with the log4cxx.dtd. **/ virtual void format(ostream& output, const spi::LoggingEventPtr& event) const; /** The XMLLayout prints and does not ignore exceptions. Hence the return value false. */ virtual bool ignoresThrowable() const { return false; } }; // class XMLLayout } // namespace xml }; // namespace log4cxx #endif // _LOG4CXX_XML_LAYOUT_H