@DevOpsSummit Authors: Elizabeth White, Pat Romanski, Liz McMillan, Yeshim Deniz, SmartBear Blog

Related Topics: @DevOpsSummit, PHP

@DevOpsSummit: Blog Post

Logging From PHP Web Frameworks Like Laravel | @DevOpsSummit [#DevOps]

Laravel is a relatively new MVC web framework for PHP that was released in 2012

So what is Laravel?

Laravel is a relatively new MVC web framework for PHP that was released in 2012. It’s also the most popular PHP project on Github at the time of this post. Like many web frameworks, Laravel boasts an easy learning-curve to get an app up and running. This was certainly the case when I used it.

While this post is focusing on logging in Laravel, its applicable to other php web frameworks, like Symfony2 and Aura to name a few. It’s worth noting that Laravel actually has several Symfony dependencies but the two can be used independently to build a web app.

When it comes to logging, each of these web frameworks have followed the PSR-3 logging standard interface.

logging-from-php-web-frameworksThis helpful standard is also implemented by Monolog, a popular PHP logging library that is inspired by Pythons Logbook library.
Thanks to this, the frameworks actually come with Monolog out of the box, making it very easy to switch between them with minimal effect to your logging configurations, should you need to migrate your app.
Setting up with Monolog is just as simple.
In the case of Laravel, we can find the default logging configuration at this location in our projects root directory:
The default config writes to a file in the projects log folder located below in the project directory:


Thanks to one of our users and contributors, Rob Kaufmann, Monolog ships with built-in Logentries support, so we need only add 2 lines to


to start sending logs to Logentries.

This snippet below shows what we need to add to configure our Laravel config to point Monolog towards Logentries:

$logentriesHandler = new Monolog\Handler\LogEntriesHandler('LOG_TOKEN');

The LogEntriesHandler has a single required parameter which is the UUID token for a log on Logentries, this allows the library to send logs to a specified log in a Logentries account.

To obtain a token, simply follow these steps:

1. Create A Log Destination

First, we need a Logentries Account, which you can get for free. Once we have a Logentries account, we’ll need a destination log in order to store the entries sent from within our Laravel app. In the Logentries UI, create a new log by clicking the Create Log button. If you already have a Host set up, you can add the log to the existing Host by click on the Host in the Web UI and then “Add new log”  as shown below:

2. Click Manual Configuration button from the list of options.


3. Give the new log a name of your choice, and then select “Token TCP”:


4. Click the Register New Log button.

A token will be displayed in green. Copy this token and insert it into your global.php resulting in a config snippet similar to this:

$logentriesHandler = new Monolog\Handler\LogEntriesHandler('COPIED_TOKEN');

Now, any log statements written by your Laravel app will now be forwarded to Logentries, it doesn’t get any easier than that.

More Stories By Trevor Parsons

Trevor Parsons is Chief Scientist and Co-founder of Logentries. Trevor has over 10 years experience in enterprise software and, in particular, has specialized in developing enterprise monitoring and performance tools for distributed systems. He is also a research fellow at the Performance Engineering Lab Research Group and was formerly a Scientist at the IBM Center for Advanced Studies. Trevor holds a PhD from University College Dublin, Ireland.

@DevOpsSummit Stories
DevOpsSummit New York 2018, colocated with CloudEXPO | DXWorldEXPO New York 2018 will be held November 11-13, 2018, in New York City. Digital Transformation (DX) is a major focus with the introduction of DXWorldEXPO within the program. Successful transformation requires a laser focus on being data-driven and on using all the tools available that enable transformation if they plan to survive over the long term. A total of 88% of Fortune 500 companies from a generation ago are now out of business. Only 12% still survive. Similar percentages are found throughout enterprises of all sizes.
For better or worse, DevOps has gone mainstream. All doubt was removed when IBM and HP threw up their respective DevOps microsites. Where are we on the hype cycle? It's hard to say for sure but there's a feeling we're heading for the "Peak of Inflated Expectations." What does this mean for the enterprise? Should they avoid DevOps? Definitely not. Should they be cautious though? Absolutely. The truth is that DevOps and the enterprise are at best strange bedfellows. The movement has its roots in the tech community's elite. Open source projects and methodologies driven by the alumni of companies like Netflix, Google and Amazon. This is a great thing for the evolution of DevOps. It can be alienating for Enterprise IT though. Learning about Netflix and their simian armies, or Facebook and their mind-melting scale is fascinating. Can you take it back to the office on Monday morning though?
For organizations that have amassed large sums of software complexity, taking a microservices approach is the first step toward DevOps and continuous improvement / development. Integrating system-level analysis with microservices makes it easier to change and add functionality to applications at any time without the increase of risk. Before you start big transformation projects or a cloud migration, make sure these changes won’t take down your entire organization.
Learn how to solve the problem of keeping files in sync between multiple Docker containers. In his session at 16th Cloud Expo, Aaron Brongersma, Senior Infrastructure Engineer at Modulus, discussed using rsync, GlusterFS, EBS and Bit Torrent Sync. He broke down the tools that are needed to help create a seamless user experience. In the end, can we have an environment where we can easily move Docker containers, servers, and volumes without impacting our applications? He shared his results so you can decide for yourself.
The Jevons Paradox suggests that when technological advances increase efficiency of a resource, it results in an overall increase in consumption. Writing on the increased use of coal as a result of technological improvements, 19th-century economist William Stanley Jevons found that these improvements led to the development of new ways to utilize coal. In his session at 19th Cloud Expo, Mark Thiele, Chief Strategy Officer for Apcera, compared the Jevons Paradox to modern-day enterprise IT, examining how the Internet and the cloud has allowed for the democratization of IT, resulting in an increased demand for the cloud and the drive to develop new ways to utilize it.