In this article we will learn how to use $log service in AngularJs or what is $log service in AngularJs or why use $log service in AngularJs with example.


AngularJs provide logging service $log, which logs the messages to the browser's console. The $log service provides different methods to log the error, information, warning or debug information. It can be useful in debugging and auditing.

following the Below different type  $log service methods:

log():Write a log message.

info():Write an information message.

warn():Write a warning message.

error():Write an error message.

debug():Write a debug message.


<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Log.aspx.cs" 
  Inherits="Example.Log" %>
<!DOCTYPE html>
<html xmlns="">
<head runat="server">
    <script src="Scripts/angular.min.js"></script>
    <body ng-app="myApp" >
    <div ng-controller="myController">
        <p>Please check the browser console for the logging information.</p>
        var myApp = angular.module('myApp', []);
        myApp.controller("myController", function ($log) {
            $log.log('This is log.');
            $log.error('This is error.');
            $'This is info.');
            $log.warn('This is warning.');
            $log.debug('This is debugging.');


How to use $log service in AngularJs

I hope this article will help to you.

Leave a comment

Make sure you enter the (*) required information where indicated. HTML code is not allowed.

You may also like