Showing posts with label Development. Show all posts
Showing posts with label Development. Show all posts

Tuesday, May 10, 2011

Remote Log4Net

You probably know this already, or this might not come as a surprise but enabling log4net to log to a remote place is really simple.

We had a scenario of only one front end with custom systems using log4net, but we needed to add a second front end, and with that the question about what to do about logging.

I wasn't aware how simple is to enable remote logging on log4net. So, heads up if you were like me:

Get log4net Remove Logging Service at CodePlex (you can get the source and change at your will), after install this will create a listener service where you want to store your remote log repository.

Then, at your local clients just change the appender to something like this

<appender name="remotAppend" type="log4net.Appender.RemotingAppender" >
<sink value="tcp://remoteserver:port/Log4netRemotingServerService" />
<lossy value="false" />
<bufferSize value="10" />
<onlyFixPartialEventData value="true" />
</appender>

At your Remote repository use your favorite appender, RollingLogFileAppender or whatever.
Remember to add the hostname property to your layout type: (%-10property{log4net:HostName}).

Something like this:

<appender name="RollLogAppender" type="log4net.Appender.RollingFileAppender">
<file value="C:\LOGS\MYAPP.log.txt" />
<appendToFile value="true" />
<rollingStyle value="Date" />
<encoding value="UTF-8" />
<datePattern value="'.'yyyy'.'MM'.'dd'.'HH'.log.txt'" />
<lockingModel type="log4net.Appender.FileAppender+MinimalLock" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%date (%-10property{log4net:HostName}) [%thread] %-5level %logger - %message%newline" />
</layout>
</appender>

Maybe you could do without this Codeplex service, but since it was so simple and the component is working fine I didnt waste any time looking for alternatives.

If you dont agree, please comment, shed some light :) Thank you.

Friday, April 24, 2009

SPUtility

The other day i discovered SPUtility, while browsing i found out some nice methods, check them out :-)


·         SPUtility.SendEmail(web, false, false, "someone@somewhere.com", subject, body);

 

·         string featurePath =SPUtility.GetGenericSetupPath("template\\features");

 

    // returns C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\FEATURES

       

 

Redirect to the SharePoint Error Page.
            This is a nice way of handling errors cleanly and consistently.

    try 
   
 
        
// some code that might fail 
    } 
   
 catch (SPException ex) 
    { 
        
SPUtility.TransferToErrorPage("An error occurred.\n" + ex.Message); 
    }

 

 

        4. Redirect to any page.
            I find this really handy as you can provide flags that let you redirect relative to the layouts directory (if you have some custom layout pages)

    // send user to login page 
    SPUtility.Redirect("login.aspx", SPRedirectFlags.RelativeToLayoutsPage,HttpContext.Current);

 

Original: http://www.trinkit.co.nz/blog/archive/2007/04/30/programming-in-wss-use-sputility.aspx

Saturday, February 21, 2009

DevDays

DevDays is the big Microsoft event in Portugal, like TechDays, but at a Portuguese scale, so a bit small but still pretty cool, this year presented in IST at Tagus Park. I went to the first day and had a great time, learn a lot about BI, something that was almost unknowned to me (i didn't knew MDX so...) and now since PerformancePoint is going to sit on top of SharePoint i thought i would be nice to learn something about it. I really liked Nelson Luciano and Rui Quintino (co worker at DevScope :) stuff on BI, the first one was very introductory but very wide, Rui's presentation was much more advanced and very informative. The new stuff from .NET 4.0 was pretty interesting and Nuno Godinho is a good&fun speaker. Parallels Extension was also very good, those work units that can scale for N cores is really great we hope more on that in the future. Too bad the SharePoint session was canceled and went to day 2 which i didn't go to. I also had time to learn a bit about Scrum and TFS in a Tiago Pascoal session that was also good.


Sunday, February 15, 2009

Visual Studio 2010 & SharePoint

For all of you that are developing in SharePoint, check it out the new Visual Studio 2010 and the goodies it has for SharePoint. Visual WebParts? Server Explorer (SPManager?;-) Feature Manager, pretty cool stuff

Check the video here.