<p dir="auto"><strong><a href="https://jira.spring.io/secure/ViewProfile.jspa?name=skaffman" rel="nofollow">Kenny MacLeod</a></strong> opened <strong><a href="https://jira.spring.io/browse/SPR-4432?redirect=false" rel="nofollow">SPR-4432</a></strong> and commented</p>
<p dir="auto">It occurred to me that a neat application of autowiring would be the ability to autowire logger objects.</p>
<p dir="auto">Say a class declares something like:</p>
<p dir="auto">private <code class="notranslate">@Autowired</code> Log logger;</p>
<p dir="auto">where Log is from commons-logging.  Spring would then generate a Log object for the declaring class and then inject it.</p>
<p dir="auto">I don't think this can be done using the existing resolveResolvableDependency mechanism, since information about the dependent class isn't made available in order to create the Log.</p>
<p dir="auto">Thoughts?</p>
<hr>
<p dir="auto"><strong>Issue Links:</strong></p>
<ul dir="auto">
<li><a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="398085331" data-permission-text="Title is private" data-url="https://github.com/spring-projects/spring-framework/issues/9109" data-hovercard-type="issue" data-hovercard-url="/spring-projects/spring-framework/issues/9109/hovercard" href="https://github.com/spring-projects/spring-framework/issues/9109">#9109</a> Support <code class="notranslate">@autowiring</code> of Loggers (<em><strong>"duplicates"</strong></em>)</li>
</ul>
<p dir="auto"><strong><a href="https://jira.spring.io/secure/ViewProfile.jspa?name=skaffman" rel="nofollow">Kenny MacLeod</a></strong> opened <strong><a href="https://jira.spring.io/browse/SPR-4431?redirect=false" rel="nofollow">SPR-4431</a></strong> and commented</p>
<p dir="auto">It occurred to me that a neat application of autowiring would be the ability to autowire logger objects.</p>
<p dir="auto">Say a class declares something like:</p>
<p dir="auto">private <code class="notranslate">@Autowired</code> Log logger;</p>
<p dir="auto">where Log is from commons-logging.  Spring would then generate a Log object for the declaring class and then inject it.</p>
<p dir="auto">I don't think this can be done using the existing resolveResolvableDependency mechanism, since information about the dependent class isn't made available in order to create the Log.</p>
<p dir="auto">Thoughts?</p>
<hr>
<p dir="auto"><strong>Attachments:</strong></p>
<ul dir="auto">
<li><a href="https://jira.spring.io/secure/attachment/20489/IAutowireCandidateFactory.java" rel="nofollow">IAutowireCandidateFactory.java</a> (<em>241 bytes</em>)</li>
<li><a href="https://jira.spring.io/secure/attachment/20393/Log.java" rel="nofollow">Log.java</a> (<em>566 bytes</em>)</li>
<li><a href="https://jira.spring.io/secure/attachment/20490/LoggerAutowireFactory.java" rel="nofollow">LoggerAutowireFactory.java</a> (<em>1.14 kB</em>)</li>
<li><a href="https://jira.spring.io/secure/attachment/20394/LogPostProcessor.java" rel="nofollow">LogPostProcessor.java</a> (<em>1.31 kB</em>)</li>
<li><a href="https://jira.spring.io/secure/attachment/20491/PluggableAutowireCandidateResolver.java" rel="nofollow">PluggableAutowireCandidateResolver.java</a> (<em>2.10 kB</em>)</li>
</ul>
<p dir="auto"><strong>Issue Links:</strong></p>
<ul dir="auto">
<li><a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="398085341" data-permission-text="Title is private" data-url="https://github.com/spring-projects/spring-framework/issues/9110" data-hovercard-type="issue" data-hovercard-url="/spring-projects/spring-framework/issues/9110/hovercard" href="https://github.com/spring-projects/spring-framework/issues/9110">#9110</a> Support <code class="notranslate">@autowiring</code> of Loggers (<em><strong>"is duplicated by"</strong></em>)</li>
</ul>
<p dir="auto">11 votes, 14 watchers</p>