Summer 16 is already in production and most of you already knows what’s there in pandora box. In this post, I will share my favorite 20 features of Summer 16 release.
1. Clone Sandbox (Pilot) : This feature is not yet generally available however worth mentioning. Till now, we could create Sandbox only from production, however Summer 16 gives us a way to create brand new sandbox from other existing sandbox instead of production.
2. New Trace Flags in Debug Log : Now we can add trace flags on Automated Process, User, Apex Trigger and Apex classes as well. Before this release, we could only add trace flag on user. This enhancement will give developers more control over what to display in debug log and overcome debug log size limit problems.
While developing applications on Force.com platform using Apex, I am sure you may have been in need of debugging your code. Salesforce being cloud platform, method to debug code is very different as compared to other programming languages. In this post we will discuss all about Apex code debugging, challenges, solutions and other best practices.
pageOutput=”true” – add the tracing information at the bottom of the ASPX page.
localOnly=”false” – tracing will be available to any web page.
requestLimit=”10″ – How many request should be saved on the server.
mostRecent=”true” – whether or not display the recent tracing information if the request reach at the limit.
After adding above tag in web.config, the output of ASP.NET page will look like:
Here you can see much of informations displayed like SessionId, Request Status, Controls available on that page, All the events of the page with start and end time etc and thus you can figure out the performance of your web application.
No Trace for a particular Page
Create a web page and in aspx file and at header write the tag Trace=”false”
Create few controls like link button and view the page in browser. You will see that the page is displayed with no tracing information, although its turned ON in web.config but page level tracing has the precedence over application level tracing.
Writing Custom Trace Information
Now on the click event of Link buttons write the custom trace information.
when you will click on the WriteLink button, below output will be seen.
and when you will click on warn button, the message will be displayed in Red color. so it is suggested to display the the important trace message as a warn.
Page.Trace Vs System.Diagnostics.Trace
Create a new class file and write a static function which will write the Trace Message. You will notice that Trace object is not available by default like ASPX page instead you will need to import the package “System.Diagnostics”.
So, there is lot difference in System.Diagnostic.Trace and Page.Trace.
Trace from Diagnostics display the trace information in output window of Visual studio whereas the Trace from page displays the Trace information in ASPX Page.
Integrate System.Diagnostics with ASPX Page (Routing all Trace information to web page)
We will need to add the listener in web.config file to route all the tracing information to the single web page.
To integrate the System.Diagnostics Trace with ASPX page, write below line of code in web.config.
.NET has provided us the flexibility of writing our own Trace Listeners in the form of the TraceListener class. Every Trace Listener is inherited from this class; therefore, in order to implement your own Trace Listener, you must inherit your Trace Listener class from this class.
TraceListener class has many virtual and abstract methods; at the very least, each inheritor of this class must implement the Write and WriteLine methods; other important methods are Fail, Close, and Flush. Inheritors are not supposed to implement these methods but it is a good idea to implement these methods. Descriptions of these methods are given in the beginning of the article.
Outputs the specified text with the Call Stack.
Outputs the specified text.
Outputs the specified text and a carriage return.
Flushes the output buffer to the target media.
Closes the output stream in order to not receive the tracing/debugging output.
Write and WriteLine methods are overloaded; following is a list of all the overloaded version of the Write method:
public override void Write(string message)
public override void Write(object o)
public override void Write(string message, string category)
public override void Write(object o, string category)
For this article, I have created a Trace Listener, DatabaseTraceListener, which actually stores trace and debug messages into a database.
add below code in Web.config which stores the connection string information.