Structuremap and LoggingConnection

195 views
Skip to first unread message

Swati S

unread,
Oct 30, 2012, 6:39:34 PM10/30/12
to sol...@googlegroups.com
I cannot figure out how to use the LoggingConnection example to get the URL that SolrNET is sending to Solr. I am unable to retrieve this URL from the jetty logs...because well, our URLs are *very* long and Jetty truncates them.

I am not sure how to "register" my Logging class:

foreach ( SolrServerElement core in solrServers )
{
var coreConnectionId = core.Id + typeof( SolrConnection );

For<ISolrConnection>().Add<LoggingConnection>()
.Named( coreConnectionId )
.Ctor<SolrConnection>( "connection" ).Is( new SolrConnection( core.Url ) {Cache = new NullCache()} );
}

Doesn't work. I also tried:

For<ISolrConnection>().Add<LoggingConnection>()
.Named( "l" + coreConnectionId )
.Ctor<SolrConnection>( "connection" ).Is( i => i.IsNamedInstance(coreConnectionId) );


Not sure how to do this :(

Thank you

Mauricio Scheffer

unread,
Nov 7, 2012, 8:53:30 AM11/7/12
to sol...@googlegroups.com
I'm not very familiar with StructureMap, but I think you can remove (called 'eject' IIRC) the SolrConnection objects registered by the SolrNetRegistry and add your own.
Otherwise, you can always copy&paste the code of SolrNetRegistry and adjust it to your needs. Ugly, but it works.

Cheers

--
Mauricio



--
You received this message because you are subscribed to the Google Groups "SolrNet" group.
To view this discussion on the web visit https://groups.google.com/d/msg/solrnet/-/02uVaHEuRTwJ.
To post to this group, send email to sol...@googlegroups.com.
To unsubscribe from this group, send email to solrnet+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/solrnet?hl=en.

Swati

unread,
Nov 7, 2012, 5:08:37 PM11/7/12
to sol...@googlegroups.com
Thanks Mauricio.

I knew very little about StructureMap as well.....and eventually gave up and instead just upgraded the version of Jetty we are using. Jetty 6 truncates URLs. Jetty 8 does not.

Thanks for responding.
Swati

Kenneth Fiduk

unread,
May 28, 2014, 12:29:06 AM5/28/14
to sol...@googlegroups.com, swati....@gmail.com
I know this thread is about 18 months old, but it's the closest I've found online to a solution to logging w/ StructureMap.

Has anyone had any luck in this regard?

Kenneth Fiduk

unread,
May 28, 2014, 1:42:43 AM5/28/14
to sol...@googlegroups.com, swati....@gmail.com
For anyone's future reference, I ended up using this to get LoggingConnection wired up (I followed the lead of SolrNetRegistry, both in the named connections and using NullCache for Cache:

    public class MySolrNetRegistry : SolrNetRegistry
    {
        private static readonly SolrConfigurationSection solrConfig = (SolrConfigurationSection) ConfigurationManager.GetSection("solr");

        public MySolrNetRegistry()
            : base(solrConfig.SolrServers)
        {
            Scan(scan =>
                {
                      // normal scanning activities
                });

            // wire up LoggingConnection decorator
            foreach (SolrServerElement server in solrConfig.SolrServers)
            {
                For<ISolrConnection>().Add<LoggingConnection>()
                                      .Named(server.Id + typeof (SolrConnection))
                                      .Ctor<SolrConnection>("connection").Is(new SolrConnection(server.Url) { Cache = new NullCache() });
Reply all
Reply to author
Forward
0 new messages