title: How do I create a custom Layout for log4cplus
body: <p>After searching for what feels far too long, I decided to ask this simple question on stackoverflow:
  How do I create a custom Layout for log4cplus (1.1.2)?
  The closest related question is <a href="https://stackoverflow.com/questions/22921728/how-do-i-add-a-custom-filter-in-log4cplus">How do I add a custom filter in log4cplus?</a> where the author adds the new class directly into the log4cplus directory (or uses log4cplus namespace?). I do not have this option as the log4plus headers and libraries are installed independently (and simply setting the namespace to log4cplus does not work either.</p>
  
  <p>What I tried is a minimal example inheriting from log4cplus::PatternLayout:</p>
  
  <pre><code>namespace myNameSpace {
    class LOG4CPLUS_EXPORT MyPatternLayout: public ::log4cplus::PatternLayout {
      public:
         MyPatternLayout(const log4cplus::tstring&amp; pattern);
         MyPatternLayout(const log4cplus::helpers::Properties&amp; properties);
        ~MyPatternLayout();
      private:
        // Disallow copying of instances of this class
        MyPatternLayout(const MyPatternLayout&amp;);
        MyPatternLayout&amp; operator=(const MyPatternLayout&amp;);
  };
  }
  </code></pre>
  
  <p>I expect that LOG4CPLUS_EXPORT takes care of registering my class to the log4cplus framework so I can use it in the configuration file. However, adding</p>
  
  <pre><code>log4cplus.appender.STDOUT.layout=myNameSpace::MyPatternLayout
  </code></pre>
  
  <p>results in an error:</p>
  
  <pre><code>log4cplus:ERROR Cannot find LayoutFactory: "myNameSpace::MyPatternLayout"
  </code></pre>
  
  <p>So how do I register a custom Layout/Appender?</p>