title: ZF2: how do I get ServiceManager instance from inside the custom class
body: <p>I'm having trouble figuring out how to get ServiceManager instance from inside the custom class.</p>
  
  <p>Inside the controller it's easy:</p>
  
  <pre><code>$this-&gt;getServiceLocator()-&gt;get('My\CustomLogger')-&gt;log(5, 'my message');
  </code></pre>
  
  <p>Now, I created a few independent classes and I need to retrieve <code>Zend\Log</code> instance inside that class. 
  In zend framework v.1 I did it through static call:</p>
  
  <pre><code>Zend_Registry::get('myCustomLogger');
  </code></pre>
  
  <p>How can I retrieve the <code>My\CustomLogger</code> in ZF2?</p>